430341 use apache jsp/jstl for maven plugins

This commit is contained in:
Greg Wilkins 2014-04-03 14:27:27 +11:00
parent 157a54ec5c
commit 0bbec3826c
5 changed files with 68 additions and 44 deletions

View File

@ -72,9 +72,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<artifactId>apache-jstl</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -79,6 +79,7 @@ import org.eclipse.jetty.util.resource.Resource;
public class JspcMojo extends AbstractMojo
{
public static final String END_OF_WEBAPP = "</web-app>";
public static final String PRECOMPILED_FLAG = "org.eclipse.jetty.jsp.precompiled";
/**
@ -207,7 +208,7 @@ public class JspcMojo extends AbstractMojo
/**
* Patterns of jars on the system path that contain tlds. Use | to separate each pattern.
*
* @parameter default-value=".*taglibs[^/]*\.jar|.*jstl-impl[^/]*\.jar$
* @parameter default-value=".*taglibs[^/]*\.jar|.*jstl[^/]*\.jar$
*/
private String tldJarNamePatterns;
@ -294,9 +295,9 @@ public class JspcMojo extends AbstractMojo
jspc.setWebXmlFragment(webXmlFragment);
jspc.setUriroot(webAppSourceDirectory);
jspc.setOutputDir(generatedClasses);
jspc.setClassPath(webAppClassPath.toString());
jspc.setClassPath(sysClassPath+System.getProperty("path.separator")+webAppClassPath.toString());
jspc.setCompile(true);
jspc.setSystemClassPath(sysClassPath);
//jspc.setSystemClassPath(sysClassPath);
// JspC#setExtensions() does not exist, so
@ -419,6 +420,10 @@ public class JspcMojo extends AbstractMojo
mergedWebXmlWriter.println(line);
}
}
//put in a context init-param to flag that the contents have been precompiled
mergedWebXmlWriter.println("<context-param><param-name>"+PRECOMPILED_FLAG+"</param-name><param-value>true</param-value></context-param>");
// put in the generated fragment
try (BufferedReader fragmentWebXmlReader = new BufferedReader(
@ -541,13 +546,16 @@ public class JspcMojo extends AbstractMojo
*/
private List<URL> getSystemJarsWithTlds() throws Exception
{
getLog().debug("tld pattern=" + tldJarNamePatterns);
final List<URL> list = new ArrayList<URL>();
List<URI> artifactUris = new ArrayList<URI>();
Pattern pattern = Pattern.compile(tldJarNamePatterns);
for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext(); )
{
Artifact pluginArtifact = iter.next();
artifactUris.add(Resource.newResource(pluginArtifact.getFile()).getURI());
Resource res = Resource.newResource(pluginArtifact.getFile());
getLog().debug("scan jar: "+res.getURI());
artifactUris.add(res.getURI());
}
PatternMatcher matcher = new PatternMatcher()

View File

@ -122,19 +122,19 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<artifactId>apache-jsp</artifactId>
<version>${project.version}</version>
</dependency>
<!-- dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.activation</artifactId>
<scope>compile</scope>
</dependency -->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<reporting>
<plugins>

View File

@ -62,7 +62,7 @@ public class JettyWebAppContext extends WebAppContext
{
private static final Logger LOG = Log.getLogger(JettyWebAppContext.class);
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$";
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar";
private static final String WEB_INF_CLASSES_PREFIX = "/WEB-INF/classes";
private static final String WEB_INF_LIB_PREFIX = "/WEB-INF/lib";

View File

@ -157,33 +157,6 @@
</loginServices>
</configuration>
</plugin>
<!-- uncomment to precompile jsps -->
<!--
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<includes>**/*.foo</includes>
<excludes>**/*.fff</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${basedir}/target/web.xml</webXml>
</configuration>
</plugin>
-->
</plugins>
</build>
<dependencies>
@ -261,4 +234,37 @@
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>precompile-jsp</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<includes>**/*.foo</includes>
<excludes>**/*.fff</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${basedir}/target/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>