[英]How can I change a config file variable using ant build?
I'm using Jboss 4/5 and have some .war .properties files with default configuration settings 我正在使用Jboss 4/5,并具有一些具有默认配置设置的.war .properties文件
I want to update these settings using information from the windows xp environment variables. 我想使用Windows XP环境变量中的信息更新这些设置。
${env} in ant $ {env} in ant
Import enviroment variables before including your property file: 在包含属性文件之前,请导入环境变量:
build.xml file: build.xml文件:
<target name="build">
<!-- load enviroment properties -->
<property environment="env" />
<property file="test.properties" />
<echo>test: ${test}</echo>
</target>
test.properties file: test.properties文件:
test = ${env.TEMP}
I needed to up the build number in several files. 我需要在几个文件中增加内部版本号。 Since I needed to keep the formatting of the file as well as the comments, I used replaceregexp . 由于我需要保留文件的格式以及注释,因此我使用了replaceregexp 。 Be careful when writing your regular expressions that you limit the expression to only find the instances that you care about. 在编写正则表达式时要小心,将表达式限制为仅查找所需的实例。
<replaceregexp
file="${dir.project}/build.properties"
match="(build\.number[ \t]*=).*"
replace="\1${build.number}"
flags="g"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.