Reputation: 7521
I have script that dosn't work becouse property once set became unwritable
<target name="test" >
<fileset id="dir1" dir="./dir1"/>
<fileset id="dir2" dir="./dir2"/>
<pathconvert property="path.converted" refid="dir1"/>
<echo message="${path.converted}"/>
<property name="path.converted" value="set this property manually"/>
<echo>${path.converted}</echo>
<pathconvert property="path.converted" refid="dir2"/>
<echo message="${path.converted}"/>
</target>
always echoed the same result, but I want that echoes was different
I read in Apache Ant 1.8.0 release, that
Lexically scoped local properties, i.e. properties that are only defined inside a target, sequential block or similar environment. This is very useful inside of s where a macro can now define a temporary property that will disappear once the task has finished.
How to use them?
Upvotes: 2
Views: 374
Reputation: 945
I would simply use different names for path.converted for the example above.
path.converted.1, path.converted.2 etc.
If you would have created a macrodef you should definitely use the local task to make the property local.
Upvotes: 0
Reputation: 7521
I found solution. Use local task
<target name="direct" depends="">
<fileset id="dir1" dir="./dir1"/>
<fileset id="dir2" dir="./dir2"/>
<!--<property name="path.converted" value="0"/>-->
<local name="path.converted"/>
<pathconvert property="path.converted" refid="dir1"/>
<echo message="${path.converted}"/>
<local name="path.converted"/>
<property name="path.converted" value="0"/>
<echo>${path.converted}</echo>
<local name="path.converted"/>
<pathconvert property="path.converted" refid="dir2"/>
<echo message="${path.converted}"/>
</target>
Upvotes: 4