When looking at the depenence sample in Ivy, came across a part where the version number gets updated as the module is published to the repositoriesthought I just post a more generic version that makes it as a Ant target.This would be useful when dealing with automated builds or when using Ivy to post to a in-house repository.
<target name="increment">
<propertyfile file="build.properties">
<entry key="build.number" type="int" operation="+" default="0"/>
</propertyfile>
<property file="build.properties"/>
<echo message="Build number is ${build.number""/>
</target>
What the above target does is that it looks for a <propertyfile> and looks for the build.number property. If both are not present it will create the file and increment the number. So if you do not have the file/property you start off with build number 1.
But the properties are not loaded in ant, that's why you need to load the property file using <property>, then you can reference build.number using normal ant properties notation.
You can test this in an ant script by calling ant increment.
So to use it to make a jar file, you probably would do something like
<jar destfile="${build.dir}/${ant.project.name}-${major}.${minor}.${build.number}.jar">....</jar>
No comments:
Post a Comment