[英]ant task to copy properties file to their corresponding place in the java build dir
[英]Does a recursive Ant task exist to recover properties from external file?
我从属性文件中获取带有ant的属性时遇到问题。 在我的build.xml中有一个简单的目标,我想要至少获得两个属性path1和path2。 我想有一个通用的目标来获得这两个属性...。以避免修改build.xml(只是添加一个新的道具)
有什么建议么? 提前致谢 !
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
谢谢,它有效。 另外,您可以使用ant-contrib的propertycopy从文件中获取其他属性。
dependencies.list=path1,path2
path1.prop1=val1
path1.prop2=val2
path2.prop1=val3
path2.prop2=val4
像这样 :
<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>
您可以将路径设置写到单个属性中的逗号分隔列表中,并使用foreach循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.