In Ant is there any way to do something like this:
<arguments id="arg-list">
<arg value="arg1" />
<arg value="arg2" />
</arguments>
<property name="prop1" refid="arg-list" />
I'm trying to write a macro for psexec and I'm looking for a nice way to pass in the argument list.
I know that you can do something similar with classpaths...
Thanks!
I don't know of an answer to your specific question. The documentation is clear that refid 'Only yields reasonable results for references to PATH like structures or properties.'
Without a bit more information on what you're trying to do, it's hard to comment. At the risk of changing your design, rather than answering your question, I suggest:
1) You can pass the argument list to exec as a line:
<macrodef name="example">
<attribute name="args"/>
<sequential>
<exec executable="example.exe">
<arg value="somearg" />
<arg line="@{args}"/>
</exec>
</sequential>
</macrodef>
<example args="somearg arg1 arg2"/>
Which will run example.exe:
example.exe arg1 arg2
2) I pass in arguments to macros that call external apps like this:
<macrodef name="example">
<element name="params" optional="yes" implicit="yes"/>
<sequential>
<exec taskname="eg" executable="example.exe">
<arg value="somearg" />
<params />
</exec>
</sequential>
</macrodef>
<example>
<arg value="arg1"/>
<arg value="arg2"/>
</example>
This will run example.exe:
example.exe somearg arg1 arg2
I hope I haven't been teaching my grandmother to suck eggs here.
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