ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mahlen Morris" <mmor...@yaltacomm.com>
Subject Personally defined properties.
Date Fri, 06 Oct 2000 01:32:49 GMT
I'm trying to figure out a way (in Ant 1.1) to allow the individual
users of my Ant files to specify their own values for properties before
my defaults are set. However, the way properties are set is not as I'm
expecting.

For example, consider these two files:

test.xml:
<?xml version="1.0"?>
<project name="foobar" default="init" basedir=".">
 
  <target name="init" >
    <available property="myprops" file="myprops.xml"/>
    <ant dir="." target="getmyprops" />
    <echo message="test1: ${dest}" />
    <property name="dest" value="c:\build" />
    <echo message="test2: ${dest}" />
  </target>

  <target name="getmyprops" if="myprops" >
    <ant dir="." antfile="myprops.xml" />
  </target>
</project>

myprops.xml:
<?xml version="1.0"?>
<project name="Yalta UN" default="myprops" basedir=".">
  <target name="myprops" >
    <property name="dest" value="c:\build2" />
    <echo message="myprops1: ${dest}" />
  </target>
</project>

My intent is that test.xml could live in source control, but if the
individual builder on their own machine regularly wants to set dest to
"c:\build2" instead of the default, they can just make a myprops.xml
file and i would set that before setting my defaults. However, the
results i get are:

C:\src\src>ant -buildfile test.xml
Buildfile: test.xml

init:

getmyprops:

myprops:
myprops1: c:\build
test1: ${dest}
test2: c:\build

BUILD SUCCESSFUL

Total time: 0 seconds

So, what appears to be happening to my fragile, procedural-language mind
is that myprops.xml gets the default value of 'dest' from test.xml, and
then test.xml forgets the defualt value, and then learns it again! Color
me confused, but this is wonderous strange! Is there a way to do what
I'm intending, i.e.,

C:\src\src>ant -buildfile test.xml
Buildfile: test.xml

init:

getmyprops:

myprops:
myprops1: c:\build2
test1: c:\build2
test2: c:\build2

BUILD SUCCESSFUL

Total time: 0 seconds

mahlen

If fortune turns against you, even jelly breaks your tooth.
        --Persian proverb

Mime
View raw message