457508 Add flag to scan exploded jars in jetty-jspc-maven-plugin
This commit is contained in:
parent
7c53dfe5a4
commit
f6b4be9abe
|
@ -35,11 +35,15 @@ import java.util.Set;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.jasper.JspC;
|
||||
import org.apache.jasper.servlet.JspCServletContext;
|
||||
import org.apache.jasper.servlet.TldScanner;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.tomcat.JarScanner;
|
||||
import org.apache.tomcat.util.scan.StandardJarScanner;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
@ -73,7 +77,7 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
*
|
||||
* @goal jspc
|
||||
* @phase process-classes
|
||||
* @requiresDependencyResolution compile
|
||||
* @requiresDependencyResolution compile+runtime
|
||||
* @description Runs jspc compiler to produce .java and .class files
|
||||
*/
|
||||
public class JspcMojo extends AbstractMojo
|
||||
|
@ -87,13 +91,42 @@ public class JspcMojo extends AbstractMojo
|
|||
*
|
||||
* Add some extra setters to standard JspC class to help configure it
|
||||
* for running in maven.
|
||||
*
|
||||
* TODO move all setters on the plugin onto this jspc class instead.
|
||||
*/
|
||||
public static class JettyJspC extends JspC
|
||||
{
|
||||
|
||||
private boolean scanAll;
|
||||
|
||||
public void setClassLoader (ClassLoader loader)
|
||||
{
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
public void setScanAllDirectories (boolean scanAll)
|
||||
{
|
||||
this.scanAll = scanAll;
|
||||
}
|
||||
|
||||
public boolean getScanAllDirectories ()
|
||||
{
|
||||
return this.scanAll;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected TldScanner newTldScanner(JspCServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
|
||||
{
|
||||
if (context != null && context.getAttribute(JarScanner.class.getName()) == null)
|
||||
{
|
||||
StandardJarScanner jarScanner = new StandardJarScanner();
|
||||
jarScanner.setScanAllDirectories(getScanAllDirectories());
|
||||
context.setAttribute(JarScanner.class.getName(), jarScanner);
|
||||
}
|
||||
|
||||
return super.newTldScanner(context, namespaceAware, validate, blockExternal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,7 +270,14 @@ public class JspcMojo extends AbstractMojo
|
|||
private JettyJspC jspc;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Whether dirs on the classpath should be scanned as well as jars.
|
||||
* True by default. This allows for scanning for tlds of dependent projects that
|
||||
* are in the reactor as unassembled jars.
|
||||
*
|
||||
* @parameter default-value=true
|
||||
*/
|
||||
private boolean scanAllDirectories;
|
||||
|
||||
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
|
@ -311,11 +351,13 @@ public class JspcMojo extends AbstractMojo
|
|||
if (jspc == null)
|
||||
jspc = new JettyJspC();
|
||||
|
||||
|
||||
jspc.setWebXmlFragment(webXmlFragment);
|
||||
jspc.setUriroot(webAppSourceDirectory);
|
||||
jspc.setOutputDir(generatedClasses);
|
||||
jspc.setClassPath(sysClassPath+System.getProperty("path.separator")+webAppClassPath.toString());
|
||||
jspc.setClassLoader(fakeWebAppClassLoader);
|
||||
jspc.setScanAllDirectories(scanAllDirectories);
|
||||
jspc.setCompile(true);
|
||||
|
||||
// JspC#setExtensions() does not exist, so
|
||||
|
|
Loading…
Reference in New Issue