Previously we covered passing command line arguments to Ant. We can use that to specify the value to be used for arg tag values. Here is an example:
ant -Dargstring="-test -abc file.out" build
In the build script we have the following:
<java classname="test.Main" fork="yes" >
<arg value="${argstring}"/>
</java>
This will result in the arguments “-test -abc file.out” being passed to the java call in the build script.
written by objects
\\ tags: ant, arg, arguments, command line, system property
Sometimes you need to pass an argument on the command line to be used by your Ant build.
You can achieve this by passing it as a system property using the -D option. eg.
ant -Dmyarg=abc build
You can then access that system property in your build script as ${myarg}. eg. The following will replace all occurrences of ‘@@@’ with the value of myarg specified on the command line (‘abc’ in the above example)
<replace dir="${src}" token="@@@" value="${myarg}">
<include name="**/*.html"/>
</replace>
written by objects
\\ tags: ant, arguments, command line, system property