ant bootstrap arg1 arg2 arg3
I need to echo "arg1 arg2 arg3" so that I can call a program with those arguments
Searching the web the following should work but does not.
<target name="bootstrap">
<echo>${arg0} ${arg1} ${arg2} </echo>
<!--exec executable="cmd">
<arg value="${arg0}"/>
<arg value="${arg1}"/>
<arg value="${arg2}"/>
</exec-->
</target>
Also, any thoughts on what if the user passes in 5 args or 1 arg. I need to fail it does not not have the right number of args.
No.
You can not pass arguments that will be used inside a build file in that way. The
ant bootstrap arg1 arg2 arg3will be resolved as you are trying to call the following targetsbootstrap,arg1,arg2,arg3— and, obviously, only the targetbootstrapexists.If you do want to pass arguments that will be used in the build file, you need to use the
-DpropertyName=valueformat. For example:For other ways, you can write embed script in the build file (like beanshell or javascript, with ant’s script support libs) to process the arguments at first. For example, you can pass the arguments in this way:
and now you have a property named
argswith the value “value1,value2,value3,…” (for … I mean that the user may type in more than 3 values). You can use beanshell to split theargstoarg1,arg2andarg3by,, and also do some checking…