Pre-compiling JSPs (JSPC) is great when you don't want users to potentially be hit with the wait for your container to compile the JSP on first visit.
Here is how to put the two together:
org.jasig.portlet WeatherPortlet ${WeatherPortlet.version} war javax.portlet portlet-api provided org.apache.pluto pluto-taglib provided org.apache.maven.plugins maven-war-plugin 2.0.2 build-directory-tree process-resources exploded org.jasig.portlet WeatherPortlet ** META-INF/context.xml build-war package war ${project.basedir}/target/jspweb.xml org.codehaus.mojo.jspc jspc-maven-plugin 2.0-alpha-3 compile ${project.basedir}/target/${project.artifactId}/WEB-INF/web.xml ${project.basedir}/target/${project.artifactId} **/*.jsp org.codehaus.mojo.jspc jspc-compiler-tomcat6 2.0-alpha-3
In the above example the following things are happening:
- The org.jasig.portlet:WeatherPortlet WAR artifact is declared as a dependency. This is the WAR that will have its JSPs compiled.
- Due to operation ordering the maven-war-plugin is split into two executions.
- First the build-directory-tree execution extracts the overlay WAR during Maven's process-resources phase. This ensures the WAR contents are in place before JSPC runs.
- Second the build-war execution re-packages the WAR using the JSPC generated XML file as the web.xml included in the WAR.
- The JSPC plugin is configured to look in the target directory for the web.xml to modify and the JSPs to compile.
No comments:
Post a Comment