Can i set an variable in available tag like this?
Yes, you can.
Macro names are changed with each iteration. The <var/>
task is simply a way to unset and reset a property in Ant. It's part of the Ant-Contrib project. You don't need to unset and reset the property:
<var name="schema.params.file" unset="true"/>
<property name="schema.params.file" value="false"/>
You could do this in a single statement:
<var name="schema.params.file" value="false"/>
Their use is highly discouraged since it breaks Ant's immutable property idea. However, I've find that I too use <var/>
a lot when going through <for/>
loops and sometimes <macrodef>
. Newer versions of Ant allow you to localize properties, so I suspect the <var/>
task will soon no longer be needed.
Another thing which may make things a bit easier is that you can use <if/>
tests with <available/>
<if>
<then>
<and>
<available file="${infinys.root}/schema_params/@{componentname}-schema_params.sql"
type="file"/>
<available file="${stage.dir}/@{componentname}/@{installableid}/schema/install/scripts"
type="dir"/>
</and>
<sequencial>
....
</sequential/>
</then>
</if>
Doing this may make your code a bit cleaner and easier to understand. It will also eliminate the need to unset properties in the first place.