ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ant question2 <antquesti...@yahoo.com>
Subject reference inside an ant task.
Date Tue, 27 Apr 2004 14:08:06 GMT
 
I am having trouble getting the ant inheritRefs to work as I would
expect it too.  I would like to set various class paths in my top level
ant file and have sub ant files be unable to change their class 
paths from what they are given.
I am using this statement to ensure that path1 is set in the main
antfile and is sent to the sub ant file.
 
     <ant antfile="b.xml" inheritRefs="true">
       <reference refid="path1"/>
     </ant>
 
Here is my sample output the first run has 
the line:       <reference refid="path1"/> 

which should cause overriding. I would expect both echo statements to
show the same output namely a.xml:
 
$ ~/ant/apache-ant-1.6.1/bin/ant -f a.xml
Buildfile: a.xml
default:
     [echo] C:\cygwin\a.xml
Overriding previous definition of reference to path1
default:
     [echo] C:\cygwin\b.xml
BUILD SUCCESSFUL
Total time: 3 seconds
 
This is the output of the second run.
I have removed the line:        <reference refid="path1"/>

Notice that in this output the line "Overriding previous definition" 
is not present yet the variables have the same values as the last run!

$ ~/ant/apache-ant-1.6.1/bin/ant -f a.xml
Buildfile: a.xml
default:
     [echo] C:\cygwin\a.xml
default:
     [echo] C:\cygwin\b.xml
BUILD SUCCESSFUL
Total time: 1 second

Here is a small ant build script which demonstrates the idea.
I have set path1 differently in files a.xml and b.xml.  I attempt to
override the path1 so that a.xml sets the path for b.xml. Unfortunatly
in my output the two path1's are showing different output.
This is not what I expected to see.  I have been looking at this
code for several days  now and have tried many different combinations
of settings yet I can not seem to get the override to work correctly.
 
<?xml version="1.0"?>
<project name="a.xml" default="default">
  <path id="path1">
    <fileset dir=".">
      <include name="a.xml"/>
    </fileset>
  </path>
  <property name="print1" refid="path1"/>
  <target name="default" >
    <echo message="${print1}" /> 
     <ant antfile="b.xml" inheritRefs="true">
<!-- The next line does not seem to effect the output at all--> 
       <reference refid="path1"/>
     </ant>
  </target>
</project>
 
<?xml version="1.0"?>
<project name="b.xml" default="default">
   <path id="path1">
    <fileset dir=".">
      <include name="b.xml"/>
    </fileset>
  </path>
  <property name="print2" refid="path1"/>
  <target name="default" >
    <echo message="${print2}" /> 
  </target>
</project>
 
 
 
 

		
---------------------------------
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message