ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: Overriding a property and subsequently derived properties
Date Wed, 01 Sep 2004 06:28:44 GMT
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
> 
> 

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