Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a variable number of arguments to ant exec

Tags:

java

ant

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?

like image 670
Pat Avatar asked Jul 21 '11 00:07

Pat


People also ask

Can we pass a variable number of arguments to a function?

Yes you can pass variable no. of arguments to a function.

How many will accept a variable number of arguments?

There can be only one variable argument in a method. Variable argument (Varargs) must be the last argument.

How to pass command line arguments in ant script?

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.

What is variable argument number?

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.


1 Answers

How about this:

 <arg line="whatever args you need"/>
like image 80
Alex Gitelman Avatar answered Nov 08 '22 02:11

Alex Gitelman