Thanks All, FYI this is my final code, tested working This appends a revision number (4th element) to a version without a revision or replaces the revision for a version that already has one. |
<available file="META-INF/MANIFEST.MF" property="has.manifest" />
<target name="loadBundleVersion" if="has.manifest">
<!-- load version, if no current build number -->
<loadproperties srcfile="META-INF/MANIFEST.MF">
<filterchain>
<linecontainsregexp>
<regexp pattern="^Bundle-Version: \d*.\d*.\d*\s*$" />
</linecontainsregexp>
</filterchain>
</loadproperties>
</target>
<target name="loadBundleVersionRemoveBuild" unless="Bundle-Version" depends="loadBundleVersion">
<!-- if version not set here we have a current build number so needs to be stripped -->
<loadproperties srcfile="META-INF/MANIFEST.MF">
<filterchain>
<linecontains>
<contains value="Bundle-Version" />
</linecontains>
<tokenfilter>
<replaceregex pattern=".\d*$" replace="" />
</tokenfilter>
</filterchain>
</loadproperties>
</target>
<target name="loadBundleDetails" depends="loadBundleVersionRemoveBuild">
<loadproperties srcfile="META-INF/MANIFEST.MF">
<filterchain>
<linecontains>
<contains value="Bundle-SymbolicName" />
</linecontains>
</filterchain>
</loadproperties>
</target>
<target name="updateManifestVersion" if="has.manifest" depends="loadBundleDetails">
<manifest file="META-INF/MANIFEST.MF" mode="update">
<attribute name="Bundle-Version" value="${Bundle-Version}.${build.number}" />
</manifest>
</target>