Reputation: 56894
I'd like to know if "Ant-based versioning" is possible, or something like it. Here's what I mean:
A common naming convention for JARs is something like MyJar-1.0.14.jar
, where MyJar
is the primary name of the JAR file, and the -1.0.14
represents the version number.
In my Ant buildscript, I'm going to have a task dist
that will look something like:
<target name="dist" depends="compile">
<jar destfile="${dist.dir}/MyJar.jar">
<!-- All the filesets to JAR up -->
</jar>
</target>
My question is: does Ant support anything that would automatically update the JARs name with the correct version number per some external scheme? Something so that the Ant target might actually look like:
<target name="dist" depends="compile">
<jar destfile="${dist.dir}/MyJar-[revision].jar">
<!-- All the filesets to JAR up -->
</jar>
</target>
Where [revision]
is the build/revision number according to some internally-defined revision scheme (perhaps defined in some other external file)?
If so, then if I am to understand my situation, then I am stuck modifying the build.xml file every time I want to JAR-up a new version of my distribution? Yes? No?
Upvotes: 1
Views: 272
Reputation: 12385
There is an ant task which will increment the build number. Its called buildNumber
Read, increment, and write a build number to the default file, build.number.
<buildnumber file="mybuild.number"/>`
Our ant processing goes something like this
1 - Version control update the build file
2 - Increment the build number
3 - Check/commit in the build number
Upvotes: 4
Reputation: 11190
Not aware of any ant task to auto-increment the number, but you should defined the revision as a property in a build.properties file which you'll import. The property file will contain a default value
revision=1.0
in the ant build.xml file
<property file="build.properties"/>
<target>
<jar destfile="${dist.dir}/MyJar-${revision}.jar>
To update the property at build time you just call the ant target with the -D value set
ant -Drevision=2.0 dist
this avoids the need to update any file at release time.
Upvotes: 0
Reputation: 10343
You can add a property and use it like that:
<jar destfile="${dist.dir}/MyJar-${revision}.jar">
Upvotes: 0