ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
Subject RE: another request for help....
Date Tue, 08 Aug 2000 21:35:45 GMT




If you check the docs, you will see that the ant task supportes nested
property elements.  So to accomplish what you want, you can use

<ant antfile="unit.xml">
  <property name="first" value="1"/>
  <property name="second" value="2" />
</ant>

<ant antfile="unit.xml">
  <property name="first" value="3" />
  <property name="second" value="4" />
</ant>

Just make sure you haven't defined properties "first" and "second" anywhere
in the build file.

If unit.xml is small with a single target (say "doit"), you may want to
consider using the antcall task.

<target name="doit">
  <!-- whatever you do... -->
</target>

<antcall target="doit">
  <property name="first" value="1"/>
  <property name="second" value="2" />
</antcall>

The antcall task is really calling the current buildfile again, with the
target attribute the default target.  The advantage to doing it this way is
that everything is in one file.   The drawback is that it isn't documented
yet (at least as far as I could see).

Glenn McAllister
TID - Software Developer - VisualAge for Java
IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey


Please respond to ant-user@jakarta.apache.org

To:        ant-user@jakarta.apache.org
cc:
Subject:        RE: another request for help....

Well, what you suggest is exactly what I want to do, but properties are
immutable (See results of your suggestion below).  Property != variable (I
learned this the hard way :-).  The XML files are parsed to completion
before
they are invoked in any way, thus it really isn't possible to have a
"variable"
in the traditional sense.

Any ideas on how we can have "variables" in Ant buildfiles?  Otherwise, I'm
gonna hafta go running back to gnumake for a while :-(



> So your global build file would be like :
>
>
> <property name="first" value="1">
> <ant buildfile="unit.xml">
>
> <property name="first" value="2">
> <ant buildfile="unit.xml">
>
>
> Hope you got what I'm getting at.
>
Yeah, here's an example buildfile snippet:

  <target name="common_subject">
       <property name="first" value="foo"/>
       <property name="second" value="bar"/>
       <ant antfile="build_nothing.xml"/>

          <property name="first" value="baz"/>
         <property name="second" value="buz"/>
         <ant antfile="build_nothing.xml"/>

          <property name="first" value="this"/>
         <property name="second" value="that"/>
         <ant antfile="build_nothing.xml"/>
 </target>

And this is the result (had to turn "verbose" on to see it):
+Target: common_subject
  +Task: property
Setting project property: first -> foo
  +Task: property
Setting project property: second -> bar
  +Task: ant
  +Task: property
[property] Override ignored for first
  +Task: property
[property] Override ignored for second
  +Task: ant
  +Task: property
[property] Override ignored for first
  +Task: property
[property] Override ignored for second
  +Task: ant


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/




Mime
View raw message