ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Grey" <>
Subject Overriding a property and subsequently derived properties
Date Tue, 31 Aug 2004 17:19:15 GMT
I have two targets A and B in a single build.xml file. Both targets 
utilise a single property X which is set differently (via an environment
Normally, I would use a command line to set the environment variable and
 call target A, then reset the environment variable and then call target
All well and good, but I wish to automate this manual process. I've 
tried using a batch file with the above, but the batch file finishes 
completely after the first target completes.
So I thought I'd get Ant to do it for me from another target C. I've 
tried using <antcall> and overriding property X, but my problem is that 
despite property Y being derived from X, property Y never changes when 
property X is overridden.
Follow ?! Is this expected ? Can anybody please help, or suggest what I 
could/should do to achieve what I want, ie property Y also changing ?
Obviously, this is a simplified test case, and just overrding property Y
 isn't ideal. In the real world, I have a multitude of other properties 
derived from the "changing" original.
<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".">
        <property environment="env"/>
        <property name="X" value="${env.MY_VARIABLE}" />
        <property name="Y" value="${X}/Y" />
        <target name="A">
               <echo message="X is ${X}"/>
               <echo message="Y is ${Y}"/>
        <target name="B">
               <echo message="X is ${X}"/>
               <echo message="Y is ${Y}"/>
        <target name="C">
               <ant antfile="temp.xml" target="A">
                       <property name="X" value="A" />
               <ant antfile="temp.xml" target="B">
                       <property name="X" value="B" />
> ant -f temp.xml C
Buildfile: temp.xml
     [echo] X is A
     [echo] Y is Z/Y
     [echo] X is B
     [echo] Y is Z/Y

Total time: 0 seconds

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message