You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Dale Anson <da...@germane-software.com> on 2003/09/28 23:18:26 UTC

All those jars...!

I downloaded the binary Ant 1.6 alpha, from the 9/9/2003 nightly build.
The 'lib' directory has 30+ jars. I regularly use Ant from within jEdit.
Typically, I put a couple of soft link in my ${user.home}/.jedit/jars to
ant.jar and optional.jar, or on Windows, I copy ant.jar and optional.jar
into the ${user.home}/.jedit/jars directory. By doing so, jEdit loads
the ant jars with it's own class loader and makes the ant jars available
to plugins. Now that Ant 1.6 has a lot of jars, this isn't convenient to
do. Any suggestions on an easy way to get all those new ant jars into
the classpath in this situation?

Thanks,

Dale


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


Re: All those jars...!

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Tue, 30 Sep 2003 05:10 am, Alexey N. Solofnenko wrote:
> Would not it be easier to provide something like antall.jar that
> includes all ANT jars in its manifest's classpath? It would solve my
> problems with ANT classloader.
>

No. It would only work if that manifest classpath included all the support 
jars needed by all the optional tasks in which case everything ends up in the 
root classloader.

What exactly are your problems with the classloader. Is this the scriptdef 
issue?

Conor


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


Re: All those jars...!

Posted by Dale Anson <da...@germane-software.com>.
Conor,

Thanks for the explanation, it makes perfect sense. I was pretty sure 
there was a good reason to have the jars separated, but didn't pick up 
on the classloader issue.

Dale


Conor MacNeill wrote:

>On Tue, 30 Sep 2003 05:04 am, Dale Anson wrote:
>  
>
>>I don't claim to understand the details of what ant-launcher is supposed
>>to do, 
>>    
>>
>
>ant-launcher is supposed to setup an appropriate classloader hierarchy to 
>launch ant. In particular it is the minimal set of classes is required to be 
>on the classpath to start Ant. 
>
>The remaining jars, including the XML parser, ant.jar and the optional jars 
>and any support jars are then loaded onto a single classloader which is used 
>to launch Ant.
>
>If you combine ant.jar and ant-launcher into a single jar, it will work for at 
>least some basic ant functions (and maybe more). What this does, however, is 
>to create a two level classloader - one containing ant.jar and a child 
>containing the optional jars and the support libraries. Dynamic loading 
>across this classloader boundary is one way. So classes in ant.jar may not be 
>able to dynamically load classes in the optional jars, etc.
>
>For example, trying to use your combo jar directly you will be unable to find 
>the javac compiler - you need to add that to the classpath used to launch 
>your jar. Even then you will not be able to run junit event though everything 
>is in place.
>
>compile-tests:
>Skipped because property 'junit.present' not set.
>
>  
>
>>I get:
>>Apache Ant version 1.6alpha compiled on September 9 2003
>>
>>    
>>
>
>Unfortunately this is not a useful test since it does not involve any dynamic 
>class loading. Try using junit.
>
>  
>
>>I spent some time yesterday trying to find the minimum set of jars files
>>required to run Ant, and by doing the above, I only need one jar. I'm
>>sure there must be a good reason to have the ant-launcher classes in a
>>separate jar, but obviously I don't know what it is or I wouldn't be
>>rambling on about it!
>>
>>    
>>
>
>That's cool. I hope the above explains it. You really need to keep launcher 
>separate as the minimal launch code so everything else ends up in the 
>appropriate classloader. You can repackage things but if you do, you need to 
>put *everything* into the one jar including the optional task support jars 
>:-)
>
>Conor
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>  
>



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


Re: All those jars...!

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Tue, 30 Sep 2003 05:04 am, Dale Anson wrote:
> I don't claim to understand the details of what ant-launcher is supposed
> to do, 

ant-launcher is supposed to setup an appropriate classloader hierarchy to 
launch ant. In particular it is the minimal set of classes is required to be 
on the classpath to start Ant. 

The remaining jars, including the XML parser, ant.jar and the optional jars 
and any support jars are then loaded onto a single classloader which is used 
to launch Ant.

If you combine ant.jar and ant-launcher into a single jar, it will work for at 
least some basic ant functions (and maybe more). What this does, however, is 
to create a two level classloader - one containing ant.jar and a child 
containing the optional jars and the support libraries. Dynamic loading 
across this classloader boundary is one way. So classes in ant.jar may not be 
able to dynamically load classes in the optional jars, etc.

For example, trying to use your combo jar directly you will be unable to find 
the javac compiler - you need to add that to the classpath used to launch 
your jar. Even then you will not be able to run junit event though everything 
is in place.

compile-tests:
Skipped because property 'junit.present' not set.

> I get:
> Apache Ant version 1.6alpha compiled on September 9 2003
>

Unfortunately this is not a useful test since it does not involve any dynamic 
class loading. Try using junit.

>
> I spent some time yesterday trying to find the minimum set of jars files
> required to run Ant, and by doing the above, I only need one jar. I'm
> sure there must be a good reason to have the ant-launcher classes in a
> separate jar, but obviously I don't know what it is or I wouldn't be
> rambling on about it!
>

That's cool. I hope the above explains it. You really need to keep launcher 
separate as the minimal launch code so everything else ends up in the 
appropriate classloader. You can repackage things but if you do, you need to 
put *everything* into the one jar including the optional task support jars 
:-)

Conor



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


AW: All those jars...!

Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
Hi Dale,

you might want to download the sources from cvs and do a build, there have
been some changes in the start up scripts which are going to apply to
ant1.6.

(I do not know if this is going to solve your problems though)

Cheers,

Antoine

-----Ursprüngliche Nachricht-----
Von: Dale Anson [mailto:danson@germane-software.com]
Gesendet: Montag, 29. September 2003 21:04
An: Ant Developers List
Betreff: Re: All those jars...!


I don't claim to understand the details of what ant-launcher is supposed
to do, but if I do:

cd ${ant.home}/lib
jar xf ant.jar
jar xf ant-launcher.jar
rm ant.jar ant-launcher.jar
jar cfm ant.jar META-INF/MANIFEST.MF META-INF/LICENSE.txt images/ org/
rm -rf META-INF/ images/ org/
java -jar ant.jar -version

I get:
Apache Ant version 1.6alpha compiled on September 9 2003

Which means that Ant is using the ant-launcher classes in the same jar.

If I change line 57 of ${ant.home}/bin/ant.bat from:
set LOCALCLASSPATH=%ANT_HOME%\lib\ant-launcher.jar;%CLASSPATH%
to:
set LOCALCLASSPATH=%ANT_HOME%\lib\ant.jar;%CLASSPATH%

and these lines in ${ant.home}/bin/ant (the shell script)
if [ -z "$LOCALCLASSPATH" ] ; then
    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
else
    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
fi

to

if [ -z "$LOCALCLASSPATH" ] ; then
    LOCALCLASSPATH=$ANT_LIB/ant.jar
else
    LOCALCLASSPATH=$ANT_LIB/ant.jar:$LOCALCLASSPATH
fi

then doing:

ant -version

gives me:

Apache Ant version 1.6alpha compiled on September 9 2003

rather than an error.

I spent some time yesterday trying to find the minimum set of jars files
required to run Ant, and by doing the above, I only need one jar. I'm
sure there must be a good reason to have the ant-launcher classes in a
separate jar, but obviously I don't know what it is or I wouldn't be
rambling on about it!

Dale


Steve Loughran wrote:

> Dale Anson wrote:
>
>> It looks like either optional.jar or ant-launcher.jar are required in
>> addition to ant.jar, see below. It might be nice to put the classes
>> from ant-launcher.jar into ant.jar.
>
>
> not possible, because the role of ant-launcher is to set up the
> classpath to load ant.jar and the other jars.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>



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



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


Re: All those jars...!

Posted by Dale Anson <da...@germane-software.com>.
I don't claim to understand the details of what ant-launcher is supposed 
to do, but if I do:

cd ${ant.home}/lib
jar xf ant.jar
jar xf ant-launcher.jar
rm ant.jar ant-launcher.jar
jar cfm ant.jar META-INF/MANIFEST.MF META-INF/LICENSE.txt images/ org/
rm -rf META-INF/ images/ org/
java -jar ant.jar -version

I get:
Apache Ant version 1.6alpha compiled on September 9 2003

Which means that Ant is using the ant-launcher classes in the same jar.

If I change line 57 of ${ant.home}/bin/ant.bat from:
set LOCALCLASSPATH=%ANT_HOME%\lib\ant-launcher.jar;%CLASSPATH%
to:
set LOCALCLASSPATH=%ANT_HOME%\lib\ant.jar;%CLASSPATH%

and these lines in ${ant.home}/bin/ant (the shell script)
if [ -z "$LOCALCLASSPATH" ] ; then
    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
else
    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
fi

to

if [ -z "$LOCALCLASSPATH" ] ; then
    LOCALCLASSPATH=$ANT_LIB/ant.jar
else
    LOCALCLASSPATH=$ANT_LIB/ant.jar:$LOCALCLASSPATH
fi

then doing:

ant -version

gives me:

Apache Ant version 1.6alpha compiled on September 9 2003

rather than an error.

I spent some time yesterday trying to find the minimum set of jars files 
required to run Ant, and by doing the above, I only need one jar. I'm 
sure there must be a good reason to have the ant-launcher classes in a 
separate jar, but obviously I don't know what it is or I wouldn't be 
rambling on about it!

Dale


Steve Loughran wrote:

> Dale Anson wrote:
>
>> It looks like either optional.jar or ant-launcher.jar are required in 
>> addition to ant.jar, see below. It might be nice to put the classes 
>> from ant-launcher.jar into ant.jar.
>
>
> not possible, because the role of ant-launcher is to set up the 
> classpath to load ant.jar and the other jars.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>



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


Re: All those jars...!

Posted by "Alexey N. Solofnenko" <A....@mdli.com>.
Would not it be easier to provide something like antall.jar that 
includes all ANT jars in its manifest's classpath? It would solve my 
problems with ANT classloader.

- Alexey.


Steve Loughran wrote:

> Dale Anson wrote:
>
>> It looks like either optional.jar or ant-launcher.jar are required in 
>> addition to ant.jar, see below. It might be nice to put the classes 
>> from ant-launcher.jar into ant.jar.
>
>
> not possible, because the role of ant-launcher is to set up the 
> classpath to load ant.jar and the other jars.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org



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


Re: All those jars...!

Posted by Steve Loughran <st...@iseran.com>.
Dale Anson wrote:
> It looks like either optional.jar or ant-launcher.jar are required in 
> addition to ant.jar, see below. It might be nice to put the classes from 
> ant-launcher.jar into ant.jar.

not possible, because the role of ant-launcher is to set up the 
classpath to load ant.jar and the other jars.


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


Re: All those jars...!

Posted by Dale Anson <da...@germane-software.com>.
It looks like either optional.jar or ant-launcher.jar are required in 
addition to ant.jar, see below. It might be nice to put the classes from 
ant-launcher.jar into ant.jar.

cd ${ant.home}/lib
java -classpath ant.jar org.apache.tools.ant.Main
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/tools/ant/launch/AntMain
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
        at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)

java -classpath ant.jar:optional.jar org.apache.tools.ant.Main
Buildfile: build.xml does not exist!
Build failed

java -classpath ant.jar:ant-launcher.jar org.apache.tools.ant.Main
Buildfile: build.xml does not exist!
Build failed



Conor MacNeill wrote:

>On Mon, 29 Sep 2003 10:27 am, Dale Anson wrote:
>  
>
>>Woops -- never mind. If I get ant.jar and optional.jar from the same
>>distribution in the path, the rest are optional, as they should be.
>>
>>    
>>
>
>optional.jar is going away IIRC.
>
>Conor
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>  
>


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


Re: All those jars...!

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Mon, 29 Sep 2003 10:27 am, Dale Anson wrote:
> Woops -- never mind. If I get ant.jar and optional.jar from the same
> distribution in the path, the rest are optional, as they should be.
>

optional.jar is going away IIRC.

Conor


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


Re: All those jars...!

Posted by Dale Anson <da...@germane-software.com>.
Woops -- never mind. If I get ant.jar and optional.jar from the same
distribution in the path, the rest are optional, as they should be.


Dale Anson wrote:
> I downloaded the binary Ant 1.6 alpha, from the 9/9/2003 nightly build.
> The 'lib' directory has 30+ jars. I regularly use Ant from within jEdit.
> Typically, I put a couple of soft link in my ${user.home}/.jedit/jars to
> ant.jar and optional.jar, or on Windows, I copy ant.jar and optional.jar
> into the ${user.home}/.jedit/jars directory. By doing so, jEdit loads
> the ant jars with it's own class loader and makes the ant jars available
> to plugins. Now that Ant 1.6 has a lot of jars, this isn't convenient to
> do. Any suggestions on an easy way to get all those new ant jars into
> the classpath in this situation?
> 
> Thanks,
> 
> Dale
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


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