tags:

views:

55

answers:

2

Hello! I would like to store the properties I read from a Java type property file in a list. Is there any way I can do that in ANT? Thanks in advance!

A: 

See Property.

<property file="foo.properties"/>
eed3si9n
+1  A: 

Properties are maps rather than lists. You can read in a set of properties from a file using the property task.

For example:

<property file="${dir}/external.properties"/>

This property file has the format as defined by the file used in the class java.util.Properties, with the same rules about how non-ISO8859-1 characters must be escaped.

When the property file is read it allows for properties in the file to be expanded. Once the file has been read, they are accessed as normal. So if external.properties contains:

test.dir=/usr/test
test.file=foo
test.target=${test.dir}/${test.file}/

You could reference test.target directly in your task:

<!-- Will create the directory structure /usr/test/foo -->
<mkdir dir="${test.target}"/>
Rich Seller