-----Original Message-----
From: Stan Kwan [mailto:sk...@anatas.com]
Sent: Wednesday, January 14, 2009 4:27 AM
To: user@ant.apache.org
Subject: append value to existing property
/*
Hi all,
Is there a way to append a new value to an existing property. for example
[...]
*/
as Jan already mentioned, once set properties are immutable (for good reasons)
when using ant 'the normal way'.
But there are ways to change a property.
1) use tasks like var from Antcontrib, Antelope
2) use <script>
a snippet with two senseless examples to get you started =
<project name="bla" default="main" basedir=".">
<!-- Import AntContrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Properties -->
<var name="filenames" value="somefile.txt"/>
<property name="foo" value="1234"/>
<target name="bla">
<echo>Before, $${filenames} => ${filenames}</echo>
<for param="file">
<path>
<fileset dir="C:/test" includes="*.txt"/>
</path>
<sequential>
<var name="basename" unset="true"/>
<basename file="@{file}" property="basename"/>
<var name="filenames" value="${filenames},${basename}"/>
</sequential>
</for>
<echo>After, $${filenames} => ${filenames}</echo>
</target>
<target name="main" depends="bla">
<echo>Before, $${foo} => ${foo}</echo>
<script language="ruby">
12.downto(1) { |i|
puts rand(i)
$project.setProperty "foo", $project.getProperty('foo') + ',' + rand(i).to_s
}
</script>
<echo>After, $${foo} => ${foo}</echo>
</target>
</project>
Regards, Gilbert
[1] http://ant-contrib.sourceforge.net/
[2] http://antelope.tigris.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org