Reputation: 59
enter code here
I want to increment my version from property file in ant build.xml
I am using below code.
It is able to increment the version but at the same time it is rounding it eg. 4.1.0 is becoming 5. my property file:
buildversion=4.1.0
my code:
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<propertyfile file="build.properties">
<entry key="buildversion" type="int" operation="+" value="1"/>
</propertyfile>
</target>
</project>
I read about propertyfile and it support only int,date and string. How I am able to do it?
Upvotes: 0
Views: 259
Reputation: 6289
Added fields for major
.minor
.release
-build
and timestamp
:
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<!-- Declare, set and increment the values -->
<propertyfile file="build.properties">
<entry key="buildmajor" type="int" default="0"/>
<entry key="buildminor" type="int" default="0"/>
<entry key="buildrelease" type="int" default="0"/>
<entry key="buildbuild" type="int" default="0" operation="+" value="1"/>
<!-- ISO timestamp -->
<entry key="buildtime" type="date" value="now" pattern="yyyy.MM.dd HH:mm:ss"/>
</propertyfile>
<!-- Re-read values -->
<property file="build.properties"/>
<!-- Set calculated value based on re-read values -->
<propertyfile file="build.properties">
<entry key="buildversion"
value="${buildmajor}.${buildminor}.${buildrelease}-${buildbuild}"/>
</propertyfile>
</target>
Also added some comments...
Upvotes: 1