将 Ant 属性回显到文件
我在将属性回显到文件时遇到问题。我很确定有一些拼写错误我现在无法发现,或者我缺少一些概念。目标是:
<target name="war" depends="build">
<propertyfile file="project-version.properties">
<entry key="build.version" type="int" operation="+" value="1"/>
</propertyfile>
<echo file="WebContent/version.txt">${major.version}.${minor.version}.${build.version}</echo>
<war destfile="dist/system.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<classes dir="target/classes"/>
</war>
</target>
它正确更新了文件project-version.properties中的密钥build.version:
#Tue Mar 29 19:14:18 BRT 2011
build.number=3
major.version=1
build.version=16
minor.version=0
但输出version.txt是:
${major.version}.${minor.version}.${build.version}
I am having problems echoing a property to a file. I am pretty sure there is some misspelling that i can not spot right now or some concept i am missing. The target is:
<target name="war" depends="build">
<propertyfile file="project-version.properties">
<entry key="build.version" type="int" operation="+" value="1"/>
</propertyfile>
<echo file="WebContent/version.txt">${major.version}.${minor.version}.${build.version}</echo>
<war destfile="dist/system.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<classes dir="target/classes"/>
</war>
</target>
It properly updates the key build.version from file project-version.properties:
#Tue Mar 29 19:14:18 BRT 2011
build.number=3
major.version=1
build.version=16
minor.version=0
But the output version.txt is:
${major.version}.${minor.version}.${build.version}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
propertyfile
任务不会将属性加载到脚本中,这就是为什么当您尝试输出它们时,ant 无法将它们扩展为任何值。要解决这个问题,您可以在更新后加载project-version.properties 文件。
The
propertyfile
task does not load the properties into the script and this is why when you try to output them, ant can't expand them to any value.To solve it, you could just load the project-version.properties file after the updating it.