You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Glen <gl...@model3.net> on 2004/01/26 00:59:36 UTC

specifying classpath for optional jars in build.xml

Is there any way to specify the classpath to use for the optional jars 
inside the build.xml?  I.e. I want to specify the location of say 
antlr.jar (or netcomponents.jar) in the build.xml rather than place them 
in the ANT_HOME/lib folders.  Is this possible while still using the 
defauilt optional tasks?

The issue I am having is we have many developer's each working on 
multiple projects.  We want to specify the jar to use via the project.  
To give a specific example we use antlr and some projects need an older 
version of antlr and some a newer.  Which means each developer must have 
either multiple installs of ant (ick!!!) or we define a new task 
<antlrx> with the specific version needed in the classpath for the task 
def (less ick but still icky).  This is NOT isolated to ANTLR (it is 
with junit, jdepend, and others). 

What I am trying to do is setup our build.xml's so we can revert to a 
version of the project in version control and generate the exact same 
build using the exact same versions of tools (antlr, junit, jdepend) 
that the original build was done with.  One way I don't want to do this 
is have ANT itself in the build system this is because most developer's 
use the ant installed with the ide.


TIA for any clever ways around this.... 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: specifying classpath for optional jars in build.xml

Posted by Jacob Kjome <ho...@visi.com>.
At 06:59 PM 1/25/2004 -0500, you wrote:
>Is there any way to specify the classpath to use for the optional jars 
>inside the build.xml?  I.e. I want to specify the location of say 
>antlr.jar (or netcomponents.jar) in the build.xml rather than place them 
>in the ANT_HOME/lib folders.  Is this possible while still using the 
>defauilt optional tasks?
>
>The issue I am having is we have many developer's each working on multiple 
>projects.  We want to specify the jar to use via the project.
>To give a specific example we use antlr and some projects need an older 
>version of antlr and some a newer.  Which means each developer must have 
>either multiple installs of ant (ick!!!) or we define a new task <antlrx> 
>with the specific version needed in the classpath for the task def (less 
>ick but still icky).  This is NOT isolated to ANTLR (it is with junit, 
>jdepend, and others).
>What I am trying to do is setup our build.xml's so we can revert to a 
>version of the project in version control and generate the exact same 
>build using the exact same versions of tools (antlr, junit, jdepend) that 
>the original build was done with.  One way I don't want to do this is have 
>ANT itself in the build system this is because most developer's use the 
>ant installed with the ide.
>
>
>TIA for any clever ways around this....

The only way to do this without making classloading changes to Ant itself 
is to remove the optional jars from ANT_HOME/lib and point to them in your 
own <classpath>'s inside your build.xml along with their dependencies.  The 
problem happens when the optional task are the parent classloader (in 
ANT_HOME/lib) in the hierarchy and can't see down into child classloaders 
(those you define in build.xml).  This is basic Java2 classloading 
behavior.  Put them all in the same classloader or put the dependencies in 
the parent classloader and the optional tasks in the child and you are good 
to go.

Jake 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org