Bug 21793 - Ant ProjectHelper not loaded correctly [set thread context classloader]
Summary: Ant ProjectHelper not loaded correctly [set thread context classloader]
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: Jared Burns CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2002-07-23 04:47 EDT by Knut Wannheden CLA
Modified: 2003-02-17 11:02 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 Knut Wannheden CLA 2002-07-23 04:47:31 EDT
Ant supports ProjectHelpers which can be plugged in by the user to set up 
projects from the source xml files.  Normally Ant's default ProjectHelper will 
be used.  If the user wants to use a custom ProjectHelper he has either to set 
the system property org.apache.tools.ant.ProjectHelper where the value is the 
fully qualified class name of the custom ProjectHelper or include a resource 
org.apache.tools.ant.ProjectHelper in the /META-INF/services directory of the 
jar containing the custom ProjectHelper (see also class sun.misc.Service).

All this works perfectly with Ant's command line frontend, but can't be 
configured with the Ant plugin in Eclipse.  (To set the system property for 
Ant's command line frontend the ANT_OPTS environment variable can be set.)  
Neither seems to be a way to specify a system property when launching the Ant 
runner nor seems the resource in /META-INF/services to be honoured.  I guess 
the latter is related to class loading somehow.

To my surprise it didn't even work when I set the system property by starting 
Eclipse with the option "-vmargs -Dorg.apache.tools.ant.ProjectHelper=...".
Comment 1 Rodrigo Peretti CLA 2002-07-23 10:04:33 EDT
email to platform-ant-dev from Knut Wannheden:

Browsing the Ant user manual I noticed that this feature isn't documented 
anywhere but in the source code ;-)  The same goes for the ant.home property 
which is set by Ant's command line frontend and is used by the core <exec> 
task.
This makes it a little bit unclear whether this is really a bug in the Ant 
plugin or not.  But if any exposed behaviour differing from Ant's command line 
frontend is regarded as a bug, then this clearly is one.
So for documentation I have to point you to the source files, where the 
classes org.apache.tools.ant.ProjectHelper and 
org.apache.tools.ant.helper.ProjectHelperImpl should capture everything about 
the feature.
Comment 2 Knut Wannheden CLA 2002-11-05 03:47:58 EST
Recently I've seen discussions on the list about using a separate thread to run 
the Ant builds.  There is even a feature request (see bug 25062) which is 
targeted for the 2.1 M3 release.  And as I understand it there is also a custom 
ClassLoader for the AntRunner to use.  If this ClassLoader were set as the 
ContextClassLoader of the thread then I think this problem with the 
ProjectHelper would be fixed.  Because Ant uses the ContextClassLoader of the 
running thread to locate the META-
INF/services/org.apache.tools.ant.ProjectHelper resource, which in turn 
specifies the ProjectHelper.  What is your opinion on this?
Comment 3 Darin Swanson CLA 2002-11-05 10:21:39 EST
Note bug 25062 is currently slated for 2.1 not necessary 2.1 M3.
The Eclipse ant support does have its own class loader.
Thanks for the suggestion and I will definately look into it.
Comment 4 Darin Swanson CLA 2002-12-13 10:41:14 EST
Moving to M5
Comment 5 Darin Swanson CLA 2003-02-12 17:05:57 EST
AntRunner now sets and restores the Thread context classloader for all builds.
Please verify.
Comment 6 Jared Burns CLA 2003-02-17 11:02:15 EST
Verified code.