Friday, February 25, 2011

Precompile JSP with Maven 2

There are situations where JDK is banned in production and only JRE allowed for use. In this case if you are using JSP there is only one option to use - precompile JSP. Here is example how to achieve that. Nothing very special, but I guess this can save some time and effort for somebody )

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${basedir}/target/jspweb.xml</webXml>
<warSourceExcludes>**/*.jsp</warSourceExcludes>
</configuration>
</plugin>
WarSourceExcludes will not package original JSPs - really makes no sence since they are just classes and appropriate servlet mappins in web.xml now.

No comments: