I have a property
base.number=100
in a property file.
I want to create values 102, 103, 105, etc, depending on the value to be added.
How can I add the numbers to the property and get the added value?
I have a property
base.number=100
in a property file.
I want to create values 102, 103, 105, etc, depending on the value to be added.
How can I add the numbers to the property and get the added value?
Ant contrib has a Math task. It can add numbers among other things. Which means you:
Here is a macro that uses the javascript scripting engine to allow arbitrary expressions:
You need no additional ant tasks or additional scripting languages for math operations, just use the builtin javascript scripting engine java ships with (since jdk 1.6, Sun's own implementation based on rhino 1.6R2) combined with ant api and put in a macrodef for resuse, i.e. :
If you need to overwrite an existing userproperty (= those properties defined on commandline via ant -f foobar.xml -Dmyuserproperty=foo ...) you have to use the method :
You can use the
<buildnumber>
task, which uses a file namebuild.number
by default. The suggestion in amine's comment link is more general: the<propertyfile>
task can set, increment, decrement, or delete properties.