On Sun, Oct 24, 2010 at 10:31 PM, hezjing <hezj...@gmail.com> wrote: > Imagine that I have a property with the value "100", then I want to add 50 > to it and get the result as 150.
Ant isn't a programming language, so it doesn't have a lot of things you'd think a programming language would have -- such as numeric processing. You can take a look at the Antcontrib package <http://ant-contrib.sourceforge.net/> that many sites use. Antcontrib contains such tasks that can emulate for loops, if/else statements, etc. It also has a few property enhancement capabilities like "math". You can do this in two ways: <property name="add1" value="100"/> <property name="add2" value="50"/> <!-- Method #1 --> <math result="sum1" arg1="${add1}" op="+" arg2="${add2}"> <!-- Method #2 --> <math result="sum2" <op type="+"> <num value="${add1}"/> <num value="${add2}"/> </op> </math> As an optional package, you need to do a <taskdef> and add in the antcontrib.jar file to your libpath. I highly recommend that you create a special directory in your project called "antlib", place the antcontrib jarfile there, and then add this to your build.xml: <taskdef resource="net/sf/antcontrib/antlib.xml"> <classpath> <fileset dir="${basedir}/antlib"/> </classpath> </taskdef> This way, people can use your build.xml without having to install the antcontrib jar file to install antcontrib and configure their ant installation to run your build. This way, the antcontrib jar is simply in your project and is a subdirectory from your build.xml file. -- David Weintraub qazw...@gmail.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org