![](/img/trans.png)
[英]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.