John D'Emic's blog about programming, integration, system administration, etc...

Thursday, July 28, 2011

Generating Roo AspectJ ITD's from Maven

I've been messing around with Spring Roo the last couple of months and something that continually bothered me was the seeming inability to generate the ITD and other Roo artifacts from Maven. This typically means you need to check the artifacts in, which is particularly annoying in the case of ITD's. I found a workaround, however, using the Maven antrun plugin. Here's what I added to my pom.xml to get it to work:


<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>validate</phase>
<configuration>
<tasks>
<exec executable="roo">
<arg value="quit"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
...


The above has the antrun plugin run roo on Maven's validation phase with the quit command. This causes Roo to start, generate missing artifacts and quit immediately. Since the antrun task doesn't fork Maven will wait until it exits prior to compiling and all should be well. This hopefully will help someone out.