Reputation: 8885
According to the Nant documentation, you can check if a target exists using the target::exists function.
Execute target "clean", if it exists.
<if test="${target::exists('clean')}">
<call target="clean" />
</if>
I've tried passing in the name of the target as a property and it doesn't seem to work.
Nant doesn't throw an error, but neither does it return true, when it should.
Essentially what I'm trying to do is this:
<property name="cleanTarget" value="${someothervariables}"/>
<if test="${target::exists('${cleanTarget}')}">
<call target="${cleanTarget}" />
</if>
Is it possible?
Upvotes: 1
Views: 1072
Reputation: 27821
You could simplify it to:
<property name="cleanTarget" value="${someothervariables}"/>
<call target="${cleanTarget}" if="${target::exists(cleanTarget)}" />
Upvotes: 0
Reputation: 8885
I worked it out, my syntax was wrong.
The correct way would be:
<property name="cleanTarget" value="${someothervariables}"/>
<if test="${target::exists(cleanTarget)}">
<call target="${cleanTarget}" />
</if>
Upvotes: 3