Ant Property echo无效

时间:2014-10-13 15:41:58

标签: ant

我有ant任务更新build.properties中的ant属性。

ant任务:

<for list="${jar.list}" param="jar">
<sequential>
<loadproperties srcfile="${basedir}/build.properties"/> 
<if>
<isset property="@{application}.cp"/>
<then>
<propertyfile file="${basedir}/build.properties">   
<entry  key="@{application}.cp" value="${path.separator}" operation="+" />
<entry  key="@{application}.cp" value="${shipment.dir}/workspace/${common.bw.jars.dirname}/@{jar}" operation="+"/>
</propertyfile>
</then>
<else>
<propertyfile file="${basedir}/build.properties">   
<entry  key="@{application}.cp" value="${shipment.dir}/workspace/${common.bw.jars.dirname}/@{jar}" operation="+"/>
</propertyfile>
</else>
</if>                                                   
</sequential>
</for>      
<loadproperties srcfile="${basedir}/build.properties"/> 
<echo>  ${@{application}.cp} </echo>

build.properties更新时没有任何问题,但是当我读取上面ant任务更新的属性时,我只得到ant任务设置的第一个值。

例如:ant任务正在创建如下属性

build.properties:

application.libs=/app/twix16/Jenkins/Buildframework/workspace/built_libraries/BP.Marko.Shared_v1.0.projlib\:/app/twix16/Jenkins/Buildframework/workspace/built_libraries/BWUnit.projlib
application.cp=/app/twix16/Jenkins/Buildframework/workspace/jars/SelectDocId.jar\:/app/twix16/Jenkins/Buildframework/workspace/jars/TextDiff.jar

但${@ {application}.cp}仅打印/app/twix16/Jenkins/Buildframework/workspace/jars/SelectDocId.jar

任何帮助都会很棒!

1 个答案:

答案 0 :(得分:0)

Ant中的属性是不可变的,请参阅http://ant.apache.org/manual/Tasks/property.html

"whoever sets a property first freezes it for the rest of the build; they are most definitely not variables."