Variable number of parameters using <macrodef> and exec

Viewed 3751

I am using exec to invoke a command line program multiple times from an ant build.xml. This command line program takes variable number of arguments for different cases.

At the moment I am calling this external program multiple time using exec and code looks cluttered. For example:

<exec dir="./deploy_abc/bin" executable="python" failonerror="true" >
    <arg line="tests.py"/>
    <arg line="-h aaa"/>
    <arg line="-u bbb"/>
    <arg line="-p ccc"/>
</exec>

<exec dir="./deploy_abc/bin" executable="python" failonerror="true" >
    <arg line="tests.py"/>
    <arg line="-h ddd"/>
    <arg line="-u eee"/>
    <arg line="-p fff"/>
    <arg value="this is second test"/>
</exec>

<exec dir="./deploy_abc/bin" executable="python" failonerror="true" >
    <arg line="tests.py"/>
    <arg line="-u bbb"/>
    <arg line="-p ccc"/>
    <arg value="this is another test"/>
</exec>

So I am planning to refactor this build.xml file using macrodef.

My question is how to pass variable number of parameters to macrodef. As it is shown above I need to pass different arguments to the exec-ed program based on the scenario.

1 Answers
Related