Nelz's Blog

Mah blogginess

Maven Is Gettting Pretty Mature

For quite some time, I’ve been a proponent of Maven. But, I did always have to admit that it was quite a challenge to adopt it. However, I’m starting to think that maybe Maven is reaching a decent maturity level.

I wanted to add JSP precompilation to my teams build of our WAR file. I did a small Google search for "maven jspc" and I got a link directly to the CodeHaus Mojo project, and specifically to the JSPC Plugin.

They suggested the following:

<project>
.
.
.
<build>
<plugins>
<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>
</configuration>
</plugin>
</plugins>
.
.
.

This worked pretty well for me, except that it blew up on some Auto-Boxing, which is a JDK 1.5 feature. The FAQ wasn’t very clear, but this is how to fix the JSPC plugin for JDK 1.5:

<project>
.
.
.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
.
.
.

This was all well and good, but it added about 30 seconds to every build that my teammates would run. (The JSPC plugin is attached to the process-classes lifecycle phase.) I want to keep the build times down as much as possible, so I decided to add the JSPC plugin under a profile:

<project>
.
.
.
<profiles>
<profile>
<id>precompile</id>
<build>
<plugins>
<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>
</configuration>
</plugin>
</plugins>
</profile>
</profiles>
.
.
.

Now, whenever someone wants to run the JSP precompilation at their workstation, all they have to do is add the -P precompile option to their maven command line. And, for CruiseControl, all I had to do was add activateprofiles="precompile" to the <maven2 …/> schedule element.

YAY for easy!