views:

39

answers:

2

I'm using Jboss 4/5 and have 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

+3  A: 

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}
Ivan Nevostruev
+1  A: 

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"
/>
Peter Schuetze