You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Erik Meade <em...@geekfarm.org> on 2000/10/26 02:40:25 UTC

Re: how to make a classpath like "/java/lib/*.jar"? once for a multi javac task build file.

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?

--
Erik Meade


RE: how to make a classpath like "/java/lib/*.jar"? once for a multi javac task build file.

Posted by Barrie Treloar <Ba...@camtech.com.au>.
On Wed, 25 Oct 2000, Erik Meade wrote:

[del]
> > And then in another classpath declaration
> > 
> >        <classpath>
> >          <fileset refid="classpath.build.lib" />
> >          <fileset refid="classpath.build.current" />
> >        </classpath>
> > 
> > Barrie Treloar
> 
> Good idea, and I hadn't thought of that, but... I still have to
> copy and past that bottom bit all over the place... I guess what
> I really want to be able to do is set my classpath in one place
> and I would like for that one place to be in the build.xml.  I
> have resorted to setting my classpath via script.

Exactly.  Thats why I would prefer the ability to id the classpath and
then, if needed, extend it.  Since I only get XML copying I can id the
classpath but I am not allowed to make modifications.

It would be much easier to type

	<classpath refid="classpath"/>

where a classpath was needed.  

However I think we are starting to tread where XSL is needed :) as a
front end to ant.

Barrie
--
Barrie Treloar
____________________________________________________________________

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



RE: how to make a classpath like "/java/lib/*.jar"? once for a multi javac task build file.

Posted by Erik Meade <em...@geekfarm.org>.
> -----Original Message-----
> From: Barrie Treloar [mailto:Barrie.Treloar@camtech.com.au]
> Sent: Wednesday, October 25, 2000 5:50 PM
> To: ant-user@jakarta.apache.org; emeade@geekfarm.org
> Subject: Re: how to make a classpath like "/java/lib/*.jar"? once for a
> multi javac task build file.
> 
> 
> 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 -->
> 
>        <classpath>
>          <fileset id="classpath.build.lib" dir="${build.lib}">
>            <include name="**/*.jar" />
>          </fileset>
>          <fileset id="classpath.build.current" dir="${build.current}">
>            <include name="**/*.jar" />
>          </fileset>
>        </classpath>
> 
> And then in another classpath declaration
> 
>        <classpath>
>          <fileset refid="classpath.build.lib" />
>          <fileset refid="classpath.build.current" />
>        </classpath>
> 
> Barrie Treloar

Good idea, and I hadn't thought of that, but... I still have to
copy and past that bottom bit all over the place... I guess what
I really want to be able to do is set my classpath in one place
and I would like for that one place to be in the build.xml.  I
have resorted to setting my classpath via script.

Erik

RE: how to make a classpath like "/java/lib/*.jar"? once for a multijavac task build file.

Posted by Barrie Treloar <Ba...@camtech.com.au>.
On Thu, 26 Oct 2000, Adam Murdoch wrote:

> Hi,
> 
> You can do this using
> 
> <path id="someid">
> 	<fileset .../>
> </path>
> 
> <javac ...>
> 	<classpath refid="someid"/>
> <javac>
> 
> Note that the classpath must be defined using a <path> element, not a
> <classpath> element.
[del]
> >        <!-- 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="compilation.directory" />
> >        </classpath>

RE: how to make a classpath like "/java/lib/*.jar"? once for a multijavac task build file.

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

You can do this using

<path id="someid">
	<fileset .../>
</path>

<javac ...>
	<classpath refid="someid"/>
<javac>

Note that the classpath must be defined using a <path> element, not a
<classpath> element.


Adam

> -----Original Message-----
> From: Barrie Treloar [mailto:Barrie.Treloar@camtech.com.au]
> Sent: Thursday, 26 October 2000 10:50 AM
> To: ant-user@jakarta.apache.org; emeade@geekfarm.org
> Subject: Re: how to make a classpath like "/java/lib/*.jar"? once for a
> multijavac task build file.
>
>
> 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 -->
>
>        <classpath>
>          <fileset id="classpath.build.lib" dir="${build.lib}">
>            <include name="**/*.jar" />
>          </fileset>
>          <fileset id="classpath.build.current" dir="${build.current}">
>            <include name="**/*.jar" />
>          </fileset>
>        </classpath>
>
> And then in another classpath declaration
>
>        <classpath>
>          <fileset refid="classpath.build.lib" />
>          <fileset refid="classpath.build.current" />
>        </classpath>
>
> 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
> structure.
>
> 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="..." />
>           <...>
>        </classpath>
>
>        <!-- 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="compilation.directory" />
>        </classpath>
>
> 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
>       declarations.
>
> Barrie
> --
> Barrie Treloar
> ____________________________________________________________________
>
>   Barrie Treloar                      Phone: +61 8 8303 3300
>   Senior Analyst/Programmer           Fax:   +61 8 8303 4403
>   Electronic Commerce Division        Email: barrie@camtech.com.au
>   Camtech (SA) Pty Ltd                http://www.camtech.com.au
>  --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---
> ____________________________________________________________________
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: how to make a classpath like "/java/lib/*.jar"? once for a multi javac task build file.

Posted by Barrie Treloar <Ba...@camtech.com.au>.
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 -->

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

And then in another classpath declaration

       <classpath>
         <fileset refid="classpath.build.lib" />
         <fileset refid="classpath.build.current" />
       </classpath>

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
structure. 

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="..." />
          <...>
       </classpath>

       <!-- 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="compilation.directory" />
       </classpath>

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
      declarations.

Barrie
--
Barrie Treloar
____________________________________________________________________

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



RE: trying to convert to 1.2...

Posted by ja...@livemedia.com.
thanks, but that doesn't seem to be it. i get the same error w/:


<exec dir="${SRC}/${FRAMEWORK}/metadata/123"^M
        executable="clean.bat"^M
        output="${SRC}/${FRAMEWORK}/metadata/123/clean.out"

/>^M



-----Original Message-----
From: ranger@scenespot.org [mailto:ranger@scenespot.org]On Behalf Of
Benjamin Reed
Sent: Wednesday, October 25, 2000 6:58 PM
To: ant-user@jakarta.apache.org
Subject: Re: trying to convert to 1.2...


james@livemedia.com wrote:

> <exec dir="${SRC}/${FRAMEWORK}/metadata/123"^M
>         command="clean.bat"^M
>         output="${SRC}/${FRAMEWORK}/metadata/123/clean.out"^M
> />^M

This syntax has changed (heh, I just went through the 1.2 conversion
today)

I believe it would now be:

<exec dir="${SRC}/${FRAMEWORK}/metadata/123"
      executable="clean.bat"
      output="${SRC}/${FRAMEWORK}/metadata/123/clean.out" />

...and if it had been, say "clean.bat all", you would have to make the
executable="clean.bat", and then have <arg value="all"/> inside of
<exec></exec>

-- 
Ben Reed a.k.a. Ranger Rick (ranger@befunk.com)
http://defiance.dyndns.org/ / http://radio.scenespot.org/
lOST: oNE 'cAPS lOCK' KEY.  rEWARD OFFERED.
Now playing on Defiance Radio: Dark Eyed Kid by William Orbit


Re: trying to convert to 1.2...

Posted by Benjamin Reed <ra...@befunk.com>.
james@livemedia.com wrote:

> <exec dir="${SRC}/${FRAMEWORK}/metadata/123"^M
>         command="clean.bat"^M
>         output="${SRC}/${FRAMEWORK}/metadata/123/clean.out"^M
> />^M

This syntax has changed (heh, I just went through the 1.2 conversion
today)

I believe it would now be:

<exec dir="${SRC}/${FRAMEWORK}/metadata/123"
      executable="clean.bat"
      output="${SRC}/${FRAMEWORK}/metadata/123/clean.out" />

...and if it had been, say "clean.bat all", you would have to make the
executable="clean.bat", and then have <arg value="all"/> inside of
<exec></exec>

-- 
Ben Reed a.k.a. Ranger Rick (ranger@befunk.com)
http://defiance.dyndns.org/ / http://radio.scenespot.org/
lOST: oNE 'cAPS lOCK' KEY.  rEWARD OFFERED.
Now playing on Defiance Radio: Dark Eyed Kid by William Orbit

RE: trying to convert to 1.2...

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

This is usually a problem with the PATH environment variable.  The 1.3 JVM
resolves the executable name relative to its' working directory (ie the one
that ant is running in), not relative to the target directory (ie the one
given in the dir attribute of <exec>).  So, if 'clean.bat' is not in the
directory you're running ant from, then you'll need to add it to your PATH,
or alternatively, use a relative path to it in command="..." or
executable="...".


Adam

> -----Original Message-----
> From: james@livemedia.com [mailto:james@livemedia.com]
> Sent: Thursday, 26 October 2000 11:28 AM
> To: ant-user@jakarta.apache.org
> Subject: trying to convert to 1.2...
>
>
> this tag:
>
> <exec dir="${SRC}/${FRAMEWORK}/metadata/123"^M
>         command="clean.bat"^M
>         output="${SRC}/${FRAMEWORK}/metadata/123/clean.out"^M
> />^M
>
> runs under 1.1, but under 1.2  produces the following during the build:
>
> metadata:
>      [exec] The command attribute is deprecated. Please use the executable
> attri
> bute and nested arg elements.
>
> BUILD FAILED
>
> L:\src\comp\1.0\src\build2.xml:644: Execute failed:
> java.io.IOException: Cr
> eateProcess: clean.bat error=2
> java.io.IOException: CreateProcess: clean.bat error=2
>         at java.lang.Win32Process.create(Native Method)
>         at java.lang.Win32Process.<init>(Win32Process.java:66)
>         at java.lang.Runtime.execInternal(Native Method)
>         at java.lang.Runtime.exec(Runtime.java:551)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
> org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
> ute.java:390)
>         at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:247)
>         at
> org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:213)
>         at
> org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:154)
>         at org.apache.tools.ant.Target.execute(Target.java:142)
>         at org.apache.tools.ant.Project.runTarget(Project.java:818)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:532)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:506)
>         at org.apache.tools.ant.Main.runBuild(Main.java:420)
>         at org.apache.tools.ant.Main.main(Main.java:149)
>
>
> any clues are appreciated.
>
> thanks,
> james@livemedia.com


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


trying to convert to 1.2...

Posted by ja...@livemedia.com.
this tag:

<exec dir="${SRC}/${FRAMEWORK}/metadata/123"^M
        command="clean.bat"^M
        output="${SRC}/${FRAMEWORK}/metadata/123/clean.out"^M
/>^M

runs under 1.1, but under 1.2  produces the following during the build:

metadata:
     [exec] The command attribute is deprecated. Please use the executable
attri
bute and nested arg elements.

BUILD FAILED

L:\src\comp\1.0\src\build2.xml:644: Execute failed: java.io.IOException: Cr
eateProcess: clean.bat error=2
java.io.IOException: CreateProcess: clean.bat error=2
        at java.lang.Win32Process.create(Native Method)
        at java.lang.Win32Process.<init>(Win32Process.java:66)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:551)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:390)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:247)
        at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:213)
        at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:154)
        at org.apache.tools.ant.Target.execute(Target.java:142)
        at org.apache.tools.ant.Project.runTarget(Project.java:818)
        at org.apache.tools.ant.Project.executeTarget(Project.java:532)
        at org.apache.tools.ant.Project.executeTargets(Project.java:506)
        at org.apache.tools.ant.Main.runBuild(Main.java:420)
        at org.apache.tools.ant.Main.main(Main.java:149)


any clues are appreciated.

thanks,
james@livemedia.com