我有ant任务更新build.properties
中的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任务正在创建如下属性
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
任何帮助都会很棒!
答案 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."