You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Nau, Michael" <Mi...@pyxis.com> on 2003/01/17 10:18:37 UTC

Referencing a path id in another build file

Is there a way to reference a path id setup in foo.xml in bar.xml?

For example:

foo.xml
=============================================  
<project name="foo" default="" basedir=".">
  <path id="foo.cp">
    <pathelement location="${lib.dir}/j2ee.jar"/>
    <pathelement location="${lib.dir}/junit.jar"/>
  </path>

  <target name="foo">
    <ant antfile="bar.xml" target="print-foo.cp"/>
  </target>  
</project>
=============================================  

bar.xml
=============================================  
<project name="bar" default="" basedir=".">
  <target name="print-foo.cp">
    <pathconvert property="formatted-path" pathsep="${line.separator}
" refid="foo.cp"/>
    <echo message="path = ${formatted-path}"/>
  </target>  
</project>
=============================================  

output
=============================================  
D:\Temp>ant -f foo.xml foo
Buildfile: foo.xml

foo:

print-foo.cp:

BUILD FAILED
file:D:/Temp/bar.xml:3: Reference foo.cp not found.

Total time: 1 second
=============================================  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Referencing a path id in another build file

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 17 Jan 2003, Michael Nau <Mi...@pyxis.com> wrote:

> Is there a way to reference a path id setup in foo.xml in bar.xml?

Take a look at <ant>'s inheritrefs attribute as well as the nested
<reference> element.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Referencing a path id in another build file

Posted by Andy Kriger <ak...@greaterthanone.com>.
You could try this...

At the top of your build.xml, use this
<!DOCTYPE project [
    <!ENTITY paths SYSTEM "file:paths.xml">
]>

And then within your build.xml
&paths;

This includes the file paths.xml in the file build.xml
The benefit is that you can isolate common elements and reuse them. The
drawback is that paths.xml must contain fragments (just the path elements
instead of a valid build file with project as its root).


-----Original Message-----
From: Nau, Michael [mailto:Michael.Nau@pyxis.com]
Sent: Friday, January 17, 2003 4:19
To: ant-user@jakarta.apache.org
Subject: Referencing a path id in another build file


Is there a way to reference a path id setup in foo.xml in bar.xml?

For example:

foo.xml
=============================================
<project name="foo" default="" basedir=".">
  <path id="foo.cp">
    <pathelement location="${lib.dir}/j2ee.jar"/>
    <pathelement location="${lib.dir}/junit.jar"/>
  </path>

  <target name="foo">
    <ant antfile="bar.xml" target="print-foo.cp"/>
  </target>
</project>
=============================================

bar.xml
=============================================
<project name="bar" default="" basedir=".">
  <target name="print-foo.cp">
    <pathconvert property="formatted-path" pathsep="${line.separator}
" refid="foo.cp"/>
    <echo message="path = ${formatted-path}"/>
  </target>
</project>
=============================================

output
=============================================
D:\Temp>ant -f foo.xml foo
Buildfile: foo.xml

foo:

print-foo.cp:

BUILD FAILED
file:D:/Temp/bar.xml:3: Reference foo.cp not found.

Total time: 1 second
=============================================

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>