jako218
jako218

Reputation: 97

Procedurally generate <arg/> tags from string with space delimiter in Ant Java Task

So effectively what I want to do is, using a string containing my set of arguments (with each argument separated by a space), generate an <arg/> tag for each argument. If <for> tags were supported in Java Tasks in Ant, it would look something like

<java classname="some_classname">
    <classpath><path location="some_path"/></classpath>
    <for list="${args_string_variable}" delimiter=" " param="p">
        <sequential>
            <arg value="@{p}"/>
        </sequential>
    </for>
</java>

However, you can't use <for> tags inside Java Tasks in Ant, so does anyone know a nice way of doing this? I couldn't find this question anywhere else, and after Googling for 2 hours I came up empty handed. Thanks in advance!

Upvotes: 2

Views: 226

Answers (1)

M A
M A

Reputation: 72854

You can do that without looping. Why not use the arg element with the line attribute, specifying "a space-delimited list of command-line arguments":

<java classname="some_classname">
    <classpath><path location="some_path"/></classpath>   
    <arg line="${args_string_variable}"/>
</java>

See https://ant.apache.org/manual/using.html#arg.

Upvotes: 2

Related Questions