【发布时间】:2011-03-27 06:36:15
【问题描述】:
在我的 build.xml 文件中,我正在增加属性文件中的构建版本号,如下所示:
<target name="minor">
<propertyfile file="build_info.properties">
<entry key="build.minor.number" type="int" operation="+" value="1" pattern="00" />
<entry key="build.revision.number" type="int" value="0" pattern="00" />
</propertyfile>
</target>
我也有类似的主要和修订条目。 (来自Build numbers: major.minor.revision)
这很好用。现在我想把这个递增的内部版本号注入到我的源代码中:
//Main.as
public static const VERSION:String = "@(#)00.00.00)@";
通过使用:
<target name="documentVersion">
<replaceregexp file="${referer}" match="@\(#\).*@" replace="@(#)${build.major.number}.${build.minor.number}.${build.revision.number})@" />
</target>
现在这种方法有效。它确实用过时的版本号替换了版本 but。因此,每当我运行 ANT 脚本时,build_info.properties 都会更新为正确的版本,但我的源代码文件使用的是预先更新的值。
我已经回显以检查在调用替换之前我确实在增加内部版本号,并且我注意到回显:
<echo>${build.minor.number}</echo>
//After updating it still shows old non updated value here but the new value in the property file.
那么有没有办法在属性文件中检索更新的值,以便我可以使用它来注入我的源代码?
干杯
【问题讨论】:
标签: ant build-process