Hi all,
So suppose that I have an ANT build file with a number of properties set in
it, and some of those properties depend on previously defined ones, like so:
<property name="pcsRootDir" value="/pcs/pcs-HEAD">
<property name="mncRootDir" value="/mnc_core/mnc_core-HEAD">
<property name="fwkRootDir" value="/server_fwk/fwk">
<property name="mncBldrSrc" value="${mncRootDir}/bldr/mnc/java/src">
... etc.
I then want to make the build file more generic, so that I can swap in new
values for those properties. I can create a *.properties file, and pass it
as a command-line param to ANT, but ANT does not recursively resolve the
values in property files.
So, is there some way to get ANT to handle these recursive definitions?
Perhaps, is there some way to include a separate XML file in the mail build
file, and this CML file contains the property definitions? I am aware that
you can map to targets in a separate XML file, but its properties are not
visible from the main build file.
Dave Rudolf
Robert Klemme - 04 Feb 2004 15:49 GMT
> Hi all,
>
[quoted text clipped - 20 lines]
>
> Dave Rudolf
You can use import:
http://ant.apache.org/manual/CoreTasks/import.html
<import file="settings-1.xml" if="settings.1"/>
<import file="settings-2.xml" if="settings.2"/>
<import file="settings-3.xml" if="settings.3"/>
<import file="settings-4.xml" if="settings.4"/>
call with "ant -Dsettings.1=t".
Regards
robert
Ville Oikarinen - 17 Feb 2004 07:32 GMT
> I then want to make the build file more generic, so that I can swap in new
> values for those properties. I can create a *.properties file, and pass it
> as a command-line param to ANT, but ANT does not recursively resolve the
> values in property files.
If I understood correctly, you mean by "recursion" that ant will evaluate
${propertyname} strings in property values. (Strictly speaking, this would only
be recursion, if the definition referred itself (=>infinite loop), but never
mind as long as we understand each other.)
I tried this and discovered no problem.
build.xml:
<project name="testing" default="echoprops">
<target name="echoprops">
<property file="${propfile1}"/>
<property file="${propfile2}"/>
<echo message="prop1=${prop1}, derivedprop=${derivedprop}"/>
</target>
</project>
p1.properties:
prop1=value1
p2.properties:
derivedprop=${prop1}/value2
If you now run "ant -Dpropfile1=p1.properties -Dpropfile2=p2.properties", you
will get the following output:
prop1=value1, derivedprop=value1/value2
Ville Oikarinen