Is there a recursive Ant task to restore properties from an external file?
I'm having a problem getting properties with ant from a properties file. With a simple target like this in my build.xml, I would like to get at least two properties path1 and path2. I would like to have a common goal to get these two properties .... to avoid modifying the build.xml file (just by adding a new prop)
Any suggestions? Thanks in advance!
build.xml:
<target name="TEST" description="test ant">
<property file="dependencies.properties"/>
<svn>
<export srcUrl="${path.prop}" destPath="${workspace}/rep/" />
</svn>
</target>
dependencies.properties:
path1.prop = /path/to/src1
path2.prop = /path/to/src2
+2
source to share
2 answers
Thanks, it works. also, you can use propertycopy from ant -contrib to get other properties from file.
dependencies.list=path1,path2
path1.prop1=val1
path1.prop2=val2
path2.prop1=val3
path2.prop2=val4
like this:
<target name="main">
<property file="dependencies.properties"/>
<foreach list="${dependencies.list}" delimiter="," param="name" target="doExtract" inheritall="true"/>
</target>
<target name="doExtract">
<propertycopy name="prop1" from="${name}.prop1" silent="true"/>
<propertycopy name="prop2" from="${name}.prop2" silent="true"/>
<svn>
<export srcUrl="${prop1}" destPath="${workspace}/rep/"" />
</svn>
</target>
+1
source to share