0
大家好,這些都是我的file.properties文件的內容,我想打印那些有真正的價值和他們的安裝位置的平臺,它是肯定的,具有真正價值的平臺將只有安裝程序: platform.win-x86=true
platform.win-x86-client=false
platform.win-x64=true
platform.linux-x86=false
installer-zip.win-x86=E:\\abc\\abc.jar
installer-zip.win-x64=E:\\def\\def.jar
如何讀取螞蟻的屬性文件
嘗試過很多事情,但也無法與我使用過的東西之一就是爲
<propertyselector property="platform.list"
delim`enter code here`iter=","
match="platform\.([^\.]*)"
select="\1"
casesensitive="false" />
<propertyselector property="zip.list"
delimiter=","
match="installer-zip\.([^\.]*)"
select="\1"
casesensitive="false" />
<target name="print.name" >
<propertycopy name="platform.name" from="platform.${platform.id}" />
<if> <equals arg1="${platform.name}" arg2="true" />
<then>
<echo>PlatForm.Id====>${platform.id}</echo>
<echo message="${platform.name}" />
<echo file="platform.properties" append="yes">${new.platform-name}=Yes${line.separator}</echo>
</then>
</if>
</target>
<target name="print.zipname" >
<propertycopy name="zip.name" from="installer-zip.${zip.id}" />
<echo>zip.Id====>${zip.id}</echo>
<echo message="${zip.name}" />
</target>
<target name="first">
<foreach list="${platform.list}"
delimiter=","
target="print.name"
param="platform.id" />
<foreach list="${zip.list}"
delimiter=","
target="print.zipname"
param="zip.id" />
</target>
雖然打印值全真平臺,但安裝程序只會打印1,然後breaks..can你幫助,請
+1提供不需要螞蟻的contrib –
感謝這一個有效的解決方案......但有另外一個也是它採用螞蟻contril所以代碼少,但是這個也可以正常工作 – user1390517
毫無疑問,Ant-contrib的「if」任務很有用。但是,我會說,每當你發現自己想要達成目標時,首先嚐試查看是否可以找到一個聲明性解決方案。這是Ant如何設計的。 – sudocode