ANT: What's the easiest way to add a version number to an embedded jar?
<?xml version="1.0" encoding="UTF-8"?>
<project name="myPlugin" default="all">
<target name="artifact.myPlugin:jar" depends="init.artifacts, compile.module.myPlugin" description="Build 'myPlugin:jar' artifact">
<mkdir dir="${artifact.output.myplugin:jar}" />
<jar destfile="${temp.jar.path.myPlugin.jar}" duplicate="preserve" filesetmanifest="mergewithoutmain">
<zipfileset file="${basedir}/META-INF/MANIFEST.MF" prefix="META-INF" />
<zipfileset dir="${myPlugin.output.dir}" />
</jar>
<!--How would I add a version number to this that reflects my projects version -->
<copy file="${temp.jar.path.myPlugin.jar}" tofile="${artifact.output.myPlugin:jar}/plugin.company.jar" />
</target>
What is the typical way people do this?
Example (pulled from the top)
<copy file="${temp.jar.path.myPlugin.jar}" tofile="${artifact.output.myPlugin:jar}/plugin.company{version}.jar" />
+3
source to share
1 answer
The simplest solution is to use the ANT buildnumber task .
<project name="myPlugin" default="all">
<property name="version" value="1.0"/>
<target...
<buildnumber/>
<jar destfile="/path/to/jar/myjar-${version}.${build.number}.jar" ...
...
</jar>
</target>
</project>
Each build will generate a unique release number:
- myjar-1.0.0
- myjar-1.0.1
- myjar-1.0.2
- ..
+7
source to share