开发者

How can I change a config file variable using ant build?

开发者 https://www.devze.com 2022-12-14 14:53 出处:网络
I\'m using Jboss 4/5 and hav开发者_如何转开发e some .war .properties files with default configuration settings

I'm using Jboss 4/5 and hav开发者_如何转开发e some .war .properties files with default configuration settings

I want to update these settings using information from the windows xp environment variables.

${env} in ant


Import enviroment variables before including your property file:

build.xml file:

<target name="build">
   <!-- load enviroment properties -->
   <property environment="env" />
   <property file="test.properties" />
   <echo>test: ${test}</echo>
</target>

test.properties file:

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. 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"
/>
0

精彩评论

暂无评论...
验证码 换一张
取 消