如何从 ant 的属性文件中添加浮点值
how to add float value from properties file in ant
enter code here
我想从 ant build.xml 中的 属性 文件增加我的版本
我正在使用下面的代码。
它能够增加版本,但同时它正在舍入它,例如。 4.1.0 正在变为 5。我的 属性 文件:
构建版本=4.1.0
我的代码:
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<propertyfile file="build.properties">
<entry key="buildversion" type="int" operation="+" value="1"/>
</propertyfile>
</target>
</project>
我阅读了有关 属性file 的信息,它仅支持 int、date 和 string。
我怎么做到的?
为 major
.minor
.release
-build
和 timestamp
:
添加了字段
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<!-- Declare, set and increment the values -->
<propertyfile file="build.properties">
<entry key="buildmajor" type="int" default="0"/>
<entry key="buildminor" type="int" default="0"/>
<entry key="buildrelease" type="int" default="0"/>
<entry key="buildbuild" type="int" default="0" operation="+" value="1"/>
<!-- ISO timestamp -->
<entry key="buildtime" type="date" value="now" pattern="yyyy.MM.dd HH:mm:ss"/>
</propertyfile>
<!-- Re-read values -->
<property file="build.properties"/>
<!-- Set calculated value based on re-read values -->
<propertyfile file="build.properties">
<entry key="buildversion"
value="${buildmajor}.${buildminor}.${buildrelease}-${buildbuild}"/>
</propertyfile>
</target>
编辑了上面的代码片段以在计算版本字符串之前重新读取更改的值。
还添加了一些评论...
enter code here
我想从 ant build.xml 中的 属性 文件增加我的版本
我正在使用下面的代码。
它能够增加版本,但同时它正在舍入它,例如。 4.1.0 正在变为 5。我的 属性 文件:
构建版本=4.1.0
我的代码:
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<propertyfile file="build.properties">
<entry key="buildversion" type="int" operation="+" value="1"/>
</propertyfile>
</target>
</project>
我阅读了有关 属性file 的信息,它仅支持 int、date 和 string。 我怎么做到的?
为 major
.minor
.release
-build
和 timestamp
:
<target name="info">
<echo>Hello World - Welcome to Apache Ant!</echo>
<!-- Declare, set and increment the values -->
<propertyfile file="build.properties">
<entry key="buildmajor" type="int" default="0"/>
<entry key="buildminor" type="int" default="0"/>
<entry key="buildrelease" type="int" default="0"/>
<entry key="buildbuild" type="int" default="0" operation="+" value="1"/>
<!-- ISO timestamp -->
<entry key="buildtime" type="date" value="now" pattern="yyyy.MM.dd HH:mm:ss"/>
</propertyfile>
<!-- Re-read values -->
<property file="build.properties"/>
<!-- Set calculated value based on re-read values -->
<propertyfile file="build.properties">
<entry key="buildversion"
value="${buildmajor}.${buildminor}.${buildrelease}-${buildbuild}"/>
</propertyfile>
</target>
编辑了上面的代码片段以在计算版本字符串之前重新读取更改的值。
还添加了一些评论...