ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Douglass <>
Subject Re: local properties
Date Mon, 30 Oct 2000 15:06:39 GMT
At 09:06 AM 10/26/2000 -0700, Dino Valente wrote:
>...The way I got around this problem is to have two files: the build.xml 
>and buildRules.xml. The buildRules file contains your normal build 
>routines. The build.xml file uses the ant task and you set the necessary 
>properties there and invoke the subbuild target:
>   <target name="package" depends="common">
>     <ant antfile="buildRules.xml">
>         <property name="name" value="MyApp"/>
>         <property name="debug" value="on"/>
>     </ant>
>   </target>

This is getting closer to what I wanted. Essentially the properties defined 
within the <ant...> </ant> context are local to that context, that is, they 
don't exist outside of it.

Actually, after some experimentation, they truly are local in scope, in 
that, if the same name property exists outside of that scope it remains 
unchanged. For example

<target name="package" depends="common">
     <property name="aprop" value="try this"/>

<target name="package" depends="common">
     <echo message="aprop=${aprop}"/>
     <ant antfile="buildRules.xml">
         <property name="name" value="MyApp"/>
         <property name="debug" value="on"/>
     <property name="aprop" value="try this changed"/>
     <echo message="aprop=${aprop}"/>

with a corresponding echo in buildRules.xml will result in

aprop=try this
aprop=try this changed
aprop=try this

The point of all this is that I want to build an application that has a 
number of variants and I want to  build them all with one command. The 
variants are specified by setting properties as parameters. I was finding 
that having set the property once I couldn't change it for the next variant 
of the application.

I think I remember reading somewhere on the list that the developer(s) of 
ant prefer to have one huge build file. I'd prefer to see continuing 
support for hierarchical builds. For example, is it a bug or is it 
intentional that the basedir property always refers to the directory 
containing the top level build file?

Mike Douglass
Senior Systems Programmer	
Server Support Services	518 276 6780(voice) 2809 (fax)
Rensselaer Polytechnic Institute 110 8th Street, Troy, NY 12180

View raw message