ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Perkins, Kristian" <Kristian.Perk...@ato.gov.au>
Subject RE: Overriding a property and subsequently derived properties
Date Wed, 01 Sep 2004 06:37:16 GMT
Also remember that you are running ant as a batch file so you will need to use the call command
if you want to continue through the batch file after ant finishes.

i.e.

set X=A
call ant A
set X=B
call ant B



Kristian


-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
Sent: Wednesday, 1 September 2004 4:29 PM
To: user@ant.apache.org
Subject: AW: Overriding a property and subsequently derived properties


The manual to <ant> sais:

Parameters
inheritAll 
  If true, pass all properties to the new Ant project. Defaults to true. 

You should try it with setting to false. Otherwise ${Y} is set and cant be changed because
props are immutable.


Jan


> -----Urspr√ľngliche Nachricht-----
> Von: Richard Grey [mailto:richard@haamdhani.com]
> Gesendet am: Dienstag, 31. August 2004 19:19
> An: user@ant.apache.org
> Betreff: Overriding a property and subsequently derived properties
> 
> 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
>  variable).
>  
> 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
>  B.
>  
> 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.
>  
> Thanks
>  
> --
>  
> <?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>
>  
>         <target name="B">
>                <echo message="X is ${X}"/>
>                <echo message="Y is ${Y}"/>
>         </target>
>  
>  
>         <target name="C">
>                <ant antfile="temp.xml" target="A">
>                        <property name="X" value="A" />
>                </ant>
>                <ant antfile="temp.xml" target="B">
>                        <property name="X" value="B" />
>                </ant>
>         </target>
>         
> </project>
>  
> --
>  
> > set MY_VARIABLE=Z
> > ant -f temp.xml C
> Buildfile: temp.xml
>  
> C:
>  
> A:
>      [echo] X is A
>      [echo] Y is Z/Y
>  
> B:
>      [echo] X is B
>      [echo] Y is Z/Y
>  
> BUILD SUCCESSFUL
> 
> Total time: 0 seconds
> 
> 


****************************************************************
                            IMPORTANT

 The information transmitted is for the use of the intended recipient only and may contain
confidential and/or legally privileged material. Any review, re-transmission, disclosure dissemination
or other use of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited and may result in severe penalties.
 If you have received this e-mail in error please notify the Privacy Hotline of the Australian
Taxation Office, telephone 13 28 69 and delete all copies of this transmission together with
any attachments. 
****************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message