Tricking Continuum : Self-Dependencies and the Antrun Plugin
Wednesday, October 24th, 2007A project I’m working on was recently added to continuum to track build success. Unfortunately, we had to include the maven antrun plugin to handle two self-dependencies that the project has. I say unfortunate, because it made life hell to get the project to build when we changed version numbers. But, I have a solution.
The theory:
- before changing the version of the project, create the future version’s self-dependency jars.
- to do that, we need to change the antrun scripts to create new jars that will be used in the next project version. Commit to subversion and run continuum build.
- then we can change the pom to the next project version and when run in continuum it uses the jar created by the last version of the project. Maven2 then thinks it has the right jar, so the dependencies pass. The antrun scripts then fire off, and create the correct new jars that will be included in the project build.
The Implementation:
- if we’re on version 32, then change the scripts to create jars for version 33, and leave the project as version 32. Commit to subversion, then in continuum run build. Now we have project 32 that created jar 33 for us.
- The version for the project can finally be updated to 33, committed to subversion, and run successfully in continuum builds.
Now, for those of you not familiar with how to get antrun working in maven2, you need to add in the pom.xml in the plugins section:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<tasks>
<echo message="To skip install modify pom to not include maven-antrun-plugin"/>
<exec
dir="${basedir}"
executable="${basedir}/installLib.sh"
failonerror="true" />
<exec
dir="${basedir}"
executable="${basedir}/installXmlbeans.sh"
failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
For the installXmlbeans script we have something like the following: (directory xsd contains those files to be converted to xml beans)
VERSION=33
touch src/main/xsd/*
mvn -P installer xmlbeans:xmlbeans
mvn -P installer install:install-file -Dfile=target/projectname-xmlbeans.jar -DgroupId=com.twopaths.projectname -DartifactId=projectname-xmlbeans -Dversion=$VERSION -Dpackaging=jar
Hopefully this saves other people from the same continuum self-dependency versioning hell.
-Garrett