You can set default values in your build.xml like this:
<property name="foo" value="bar"/>
Which I recommend. These in turn can be overwritten by reading in a
properties file. For example, if you have a file build.properties that
looks like this:
# Overrides "foo" in the build.xml file
foo=munged-foo-value
And your build.xml file looks like this:
<project name="test" default="test" basedir=".">
<property file="build.xml"/>
<property name="foo" value="foo-value"/>
<target name="test">
<echo>Property "foo" is set to "${foo}"</echo>
</target>
</project>
The output of this build.xml will be:
[echo] Property "foo" is set to "munged-foo-value"
By changing the property file, you affect the values of the properties
you have set in your build.xml file, and it will override anything
properties you've set in your build.xml file. If you don't have a
properties file called build.xml, the <property file="build.xml"/>
will be ignored and the output will be:
[echo] Property "foo" is set to "foo-value"
You can make things a bit more flexible by doing this:
<project name="test" default="test" basedir=".">
<!-- Setting build.file to "build.properties -->
<property name="prop.file" value="build.properties"/>
<!--- Using "${prop.file} property instead of string "build.properties" -->
<!-- Can be overwritten on the command line -->
<property file="${prop.file}"/>
<property name="foo" value="foo-value"/>
<target name="test">
<echo>Property "foo" is set to "${foo}"</echo>
</target>
</project>
This way, if a user doesn't have a build.properties file, the default
value in the build.xml will be used. If the user has a
build.properties file, the value in that file will be used. If the
user gives a "-Dprop.file="my.properties", then the value set in
"my.properties" will be used.
This is the way to replace the values of properties in a build.xml file.
Is this what you're looking for?
On 6/12/07, arijit <[EMAIL PROTECTED]> wrote:
I have a build file test.xml which has lines in it which need to be replaced
by actual values. These actual values are read from a property file, which
is loaded by this build file.
This problem is similar to the thread "Token based loading of property
files" posted earlier in this forum. Have not received a response to that as
well.
any information for this ?
--
View this message in context:
http://www.nabble.com/replacing-sections-of-build-file-tf3907642.html#a11079129
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
--
David Weintraub
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]