ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barrie Treloar <>
Subject Re: how to make a classpath like "/java/lib/*.jar"? once for a multi javac task build file.
Date Thu, 26 Oct 2000 00:49:58 GMT
On Wed, 25 Oct 2000, Erik Meade wrote:

> Nico posted this a while back when asked 'how to make a classpath like
> "/java/lib/*.jar"?'
> >     <javac  srcdir="${build.src}"
> >             destdir="${build.classes}"
> >             includes="**/*.java"
> >             debug="off" optimize="on">
> >       <classpath>
> >         <fileset dir="${build.lib}">
> >           <include name="**/*.jar" />
> >         </fileset>
> >         <fileset dir="${build.current}">
> >           <include name="**/*.jar" />
> >         </fileset>
> >       </classpath>
> >     </javac>
> Does anyone know of a way to "do this" for the classpath in such a way that
> I don't
> have to cut and past this into the 13 javac tasks in a build file?

You can do this:

       <!-- Include id attributes to fileset so they can be -->
       <!-- xml pasted into other tags -->

         <fileset id="" dir="${build.lib}">
           <include name="**/*.jar" />
         <fileset id="" dir="${build.current}">
           <include name="**/*.jar" />

And then in another classpath declaration

         <fileset refid="" />
         <fileset refid="" />

What is annoying at the moment is that I must define sub-path elements
to classpath so that I can then textually include them via the refid
construct.  As thats all the refid does, a textual copy of the xml

It would be more intuitive if I could give classpath an id and then
use that as a base to extend from.

Note: the following does not work with ant, I'm hoping someone can
come up with a way to get soemthing like it to work.

       <!-- A classpath for compilation -->
	   <classpath id="classpath>
          <pathelement location="..." />

       <!-- A classpath for testing it just merely  -->
       <!-- adds the directory where the classes where compiled -->
       <!-- to the one used to compile the classes, perhaps including -->
       <!-- some additional runtime jars -->
       <classpath refid="classpath>
          <pathelement location="" />

The way I have to do this now is to 
	- somehow wrap the <pathelement> tags into a structure I can use
      the refid attribute (couldn't work out a way to do this)
    - cut-and-paste
    - include the additional values in the compile classpath (even
      though they are not needed) and then reference that classpath
      elsewhere.  This isn't any more sophisticated than defining 
      a classpath property and using that in the classpath

Barrie Treloar

  Barrie Treloar                      Phone: +61 8 8303 3300
  Senior Analyst/Programmer           Fax:   +61 8 8303 4403 
  Electronic Commerce Division        Email:
  Camtech (SA) Pty Ltd      
 --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---

View raw message