I have a ant target that takes a variable number of arguments that are to be passed to an exec task. Using the old mechanism it is trivial:
<exec command="cmd /c ${_full-path-to-exec}" osfamily="windows" failonerror="true">
</exec>
However, use of 'command' is deprecated in favor of nested elements. like this:
<exec executable="cmd" osfamily="windows" failonerror="true">
<arg value="/c"/>
<arg file="${_full-path-to-exec}"/>
<arg value="${_param-one}"/>
<arg value="${_param-two}"/>
<arg value="${_param-three}"/>
</exec>
which makes variable argument lists impossible.
How to solve this problem?
Yes you can pass variable no. of arguments to a function.
There can be only one variable argument in a method. Variable argument (Varargs) must be the last argument.
It is a single line command line argument having space characters. A command line argument with two separate options : -l and -a. when we run only ant from command line without any argument, Ant look for the default file build. xml and execute target.
To call a function with a variable number of arguments, simply specify any number of arguments in the function call. An example is the printf function from the C run-time library. The function call must include one argument for each type name declared in the parameter list or the list of argument types.
How about this:
<arg line="whatever args you need"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With