Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 217370

Summary: AntCorePreferences assumes the wrong plug-in to contribute Ant libraries
Product: [Eclipse Project] Platform Reporter: Mirko Raner <mirko>
Component: AntAssignee: Platform-Ant-Inbox <platform-ant-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Darin_Swanson, dj.houghton, Michael_Rennie
Version: 3.3.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Mirko Raner CLA 2008-01-31 19:17:45 EST
Build ID: M20071023-1652

Steps To Reproduce:
1. Install the Jtest 8.1 on Eclipse 3.3
2. Open the Window -> Preferences... -> Ant -> Runtime dialog page
3. Expand the "Ant Home Entries (Default)" classpath node
4. Notice that a bunch of Jtest plug-ins are listed (instead of Ant's lib
   folder)

Optionally:

5. Click the "Restore Defaults" button
6. Notice the error message
   "Specified Ant home does not contain a "lib" directory"


More information:

This new bug was introduced by the fix for bug 167291 in rev. 1.99 of AntCorePreferences.java. Essentially, Darin's only worry (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=167291#c5) came true, and there is another plug-in that exports the org.apache.tools.ant package.

For various reasons, the Jtest feature for Eclipse contains a library plug-in that, among other things, exports a particular version of ant.jar. The new code for AntCorePreferences.getDefaultAntHomeEntries() that was introduced in rev. 1.99 no longer looks specifically for the org.apache.ant plug-in, but searches for an exported org.apache.tools.ant package instead (see http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ant.core/src/org/eclipse/ant/core/AntCorePreferences.java?r1=1.98&r2=1.99).

The new code does compare version numbers, but when running the code in the debugger it turns out that the affected Ant packages carry the version 0.0.0. The org.apache.tools.ant package exported by Jtest overrides the original package exported by the org.apache.ant plug-in simply because the Jtest package comes after the original Ant package.

I am not really familiar with bug 167291, which prompted the code change, but I do think that this is an error-prone way of locating the plug-in that contributes the Ant functionality. If there is some other way of finding the Ant  plug-in (that still preserves the fix for bug 167291) I would strongly suggest to go down that other route. After all, any plug-in could export a package called org.apache.tools.ant.

I can imagine a few "quick fixes" for the immediate problem, though:

- check whether the JAR file that contributes the org.apache.tools.ant package
  is actually located in directory called "lib"
- use additional information from contributing plug-in's manifest to determine
  whether a plug-in is the intended main contributor for Ant functionality

For our particular problem, we might find a temporary work-around but it would be great if this issue could be fixed for the next Eclipse release.
Comment 1 Darin Swanson CLA 2008-01-31 20:19:48 EST
Mirko, thank you for the great diagnosis. 
Man, I hate it when I am right :-)
Comment 2 Michael Rennie CLA 2009-05-14 13:22:05 EDT

*** This bug has been marked as a duplicate of bug 275839 ***