All*_*lan 10 ant build-process
在我的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>
Run Code Online (Sandbox Code Playgroud)
我也有类似的主要和修订条目.(来自Build号码:major.minor.revision)
这非常有效.现在我想采用这个递增的内部版本号并将其注入我的源代码中:
//Main.as
public static const VERSION:String = "@(#)00.00.00)@";
Run Code Online (Sandbox Code Playgroud)
通过使用:
<target name="documentVersion">
<replaceregexp file="${referer}" match="@\(#\).*@" replace="@(#)${build.major.number}.${build.minor.number}.${build.revision.number})@" />
</target>
Run Code Online (Sandbox Code Playgroud)
现在这种方式有效.它确实取代了版本,但使用了过时的版本号.因此,每当我运行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.
Run Code Online (Sandbox Code Playgroud)
那么有没有办法检索属性文件中的更新值,以便我可以使用它来注入我的源代码?
干杯
All*_*lan 11
因此,在花了几个小时无法解决这个问题后,我发布了这个问题,然后在20分钟后弄明白了.
问题是我在构建文件的顶部有这个:
<property file="build_info.properties"/>
Run Code Online (Sandbox Code Playgroud)
我想这是由于范围界定和属性是不可变的,因此我永远无法更新值.删除该行,然后添加以下内容使其完美运行:
<target name="injectVersion">
<property file="build_info.properties"/>
<replaceregexp file="${referer}" match="@\(#\).*@" replace="@(#)${build.major.number}.${build.minor.number}.${build.revision.number})@" />
</target>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8114 次 |
| 最近记录: |