Evaluate Changelogic without registration!
  

Using Changelogic with Maven 2


If you are using Maven 1.x, you should look at this page: Maven 1 integration


Tip for transferring version numbers from Changelogic's version.properties files to Maven's Project Object Model (POM) files.


The contents of the version.properties file is established during the integration pass. So, if one wants to modify the contents of other files with respect to it, and wants these modifications to become part of the version, it has to be accomplished during the integration pass as well. Updating artifact's version in the POM file makes a good example here.


The contents of the POM file from the base version:
<project>

<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.3.4.5</version>
..

</project>


Contents of the newly-created version.properties file:
cl.version.stage=1
cl.version.milestone=4
cl.version.submilestone=0
cl.version.version=1


The contents of the POM file after synchronization with the version.properties file (desired):
<project>

<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.4.0.1</version>

</project>


Luckily enough, this mundane task of editing pom.xml files by hand can be automated with some knowledge about Ant and XSL transformations.


Firstly, set up a stylesheet to replace the contents of version elements as specified by the global XSL parameter named “cl.versionString”, and to perform an identity transformation on other elements (see the attached file “update_pom.xsl”). Don't forget to pay attention to XML namespaces!


If you happened to equip the project element of your pom.xml with a namespace declaration, be sure to use it in your stylesheet too:


The pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0">
</project>


The edit_pom.xsl:
<stylesheet

xmlns:pom="http://maven.apache.org/POM/4.0.0"
<xsl:template match="/pom:project/pom:version">
</xsl:template>

</stylesheet>


Secondly, add the target “update_pom” to project's Ant build file (see the attached file “update_pom.xml”). To instruct CL to invoke this target at the right moment of time, add “update_pom” to the list of integration build targets specified (property cl.integration.buildTargets in changelogic-project.properties):
cl.integration.buildTargets=clean,update_pom,compile,package