Bug 26609 - Ant config always includes optional.jar
Summary: Ant config always includes optional.jar
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows NT
: P3 major (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2002-11-18 15:02 EST by Matthew Conway CLA
Modified: 2003-01-30 10:00 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Conway CLA 2002-11-18 15:02:10 EST
Using 2.1-M3, if I setup my ExternalTools/Ant configuration to NOT include
optional.jar, it still gets included.  To duplicate, remove optional.jar in
Preferences, and run the following build file.  It runs successfully even though
<propertyfile/> is in optional.jar.  This causes grief to anyone trying to
declaratively setup ant classloaders in their build files rather than just
putting all jars in ANT_HOME/lib - optional.jar typically needs to be in the
same classloader as all the jars it depends on e.g. bsf.jar and the script task

<project name="bar" default="all">
	<target name="all">
		<echo message="Howdy"/>
		<propertyfile file="foo.properties">
			<entry key="foo" value="bar"/>
		</propertyfile>
		<echo message="Doody"/>
	</target>
</project>

Also, using a brand new eclipse 2.1M3 install with a new workspace, if I remove
optional.jar from Ant classpath, click ok, subsequently returning to the
preferences dialog shows it is gone, but when I restart eclipse, it reappears
(i.e. not being saved) - this may be related to bug 26061
Comment 1 Darin Swanson CLA 2002-11-19 01:59:56 EST
The optional.jar URL is not being explicitly added to the Ant classloader.
We should take a look at what we are getting for free from some of the 
associated plugin class loaders.

I could not reproduce the preferences problem.
Comment 2 Matthew Conway CLA 2002-11-19 10:56:42 EST
The preferences problem seems to have been fixed between M3 and todays build.
The optional.jar problem still stands.
Comment 3 Darin Swanson CLA 2002-12-14 11:12:49 EST
Need to investigate now that core resources is no longer directly pre-req'ing 
org.apache.ant.
Comment 4 Darin Swanson CLA 2003-01-29 11:00:17 EST
So I have found the root of the problem for this issue...it is the classpath 
entry in the manifest file of the ant.jar provided from apache.

Our AntClassLoader is a subclass of URLClassLoader.  If a jar on the classpath 
for the classloader has the classpath entry in the manifest, the jars listed in 
the manifest are added to the classpath as well.

Matt,  when you are doing this from the commandline, do you remove the 
optional.jar from the ANT_HOME/lib directory?
Comment 5 Matthew Conway CLA 2003-01-29 11:34:08 EST
Yes, luckily I renamed optional.jar to ant-optional.jar in ANT_HOME/lib - which
is probably why I don't have this problem on the command line.
Comment 6 Darin Swanson CLA 2003-01-29 14:13:17 EST
Going to have to mark this as won't fix. (README).

Removing the entries from the JAR manifest files can break forked tasks (such 
as junit).

The workaround is to set an ANT_HOME that:
 does not include the optional.jar or has been renamed
 the jars in the lib directory have all had the manifest file changed.
Comment 7 Darin Swanson CLA 2003-01-30 10:00:46 EST
From the ant-dev mailing list:

> I vaguely remember discussions about pulling those entries out of
> ant.jar's manifest, and having an empty JAR with them defined!?!? Is
> that in 1.6?

Yes.

ant.jar in 1.6 has 

Manifest-Version: 1.0
Main-Class: org.apache.tools.ant.Main

and nothing else.  There is an ant-bootstrap.jar that contains
Main.class and a manifest with

Class-Path: ant.jar xml-apis.jar xercesImpl.jar optional.jar xalan.jar