Bug 166449 - Don't abort build when CompilationParticipants fix classpath
Summary: Don't abort build when CompilationParticipants fix classpath
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-01 01:39 EST by Walter Harley CLA
Modified: 2007-04-27 21:10 EDT (History)
4 users (show)

See Also:


Attachments
suggested patch for 3.2.1 (1.99 KB, patch)
2006-12-01 01:55 EST, Walter Harley CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Harley CLA 2006-12-01 01:39:19 EST
A Java build starts by JavaBuilder.initializeBuilder() calling CompilationParticipant.aboutToBuild() for each participant.  The purpose of this call is in part for the participant to make sure that it has the resources it needs to build - in particular, to create any output directories it needs.

The build then goes on to call isWorthBuilding(), which calls isClassPathBroken().  But rather than actually checking the classpath, all that does is look at existing markers to see if there are any classpath problems.

If there is a missing directory that is a source path (e.g., the APT generated source folder), then there will be a classpath error marker.  Ideally when the participant (APT) creates the missing directory, it would also remove the error marker; but it can't, because the participant has no way of knowing which marker(s) to remove.

So instead what happens is that build is aborted because of the unbound source folder; and then, hopefully, a resource change event triggered by creation of the directory causes a subsequent build to occur.

In practice, that resource event seems a bit unreliable.  We are encountering situations where the change event does not seem to be getting noticed, or if it is getting noticed it is getting thrown away again, possibly because there are conflicting jobs in the queue at the same time.

So we would like a more reliable approach.  I think a good approach would be, if isClasspathBroken() returns true, to actually validate the classpath again before aborting the build.

I have tested this approach and it does fix some nasty bugs we're fighting.  However, I don't know whether I've done it the most efficient or correct way.  I'll attach the patch that I've been using as a sample.
Comment 1 Walter Harley CLA 2006-12-01 01:55:01 EST
Created attachment 54867 [details]
suggested patch for 3.2.1

Here's the patch I've been testing on 3.2.1.  It won't work on 3.3 because JavaProject methods have changed; my test scenario involves a lot of WTP plug-ins so I can't test on 3.3 yet, so I'm not sure how this should be done on 3.3.
Comment 2 Jess Garms CLA 2007-03-27 14:30:44 EDT
Any chance of getting this in for M7?
Comment 3 Kent Johnson CLA 2007-03-27 15:32:26 EDT
Jerome - updateClasspathMarkers() was removed.

Is there another way we can force the classpath markers to be recomputed?
Comment 4 Jerome Lanneluc CLA 2007-03-28 02:43:55 EDT
I thought the resolution of this bug was make the APT generated source folder optional (see IClasspathAttribute#OPTIONAL)
Comment 5 Kent Johnson CLA 2007-03-28 10:27:23 EDT
If the optional tag doesn't do the trick, let us know.
Comment 6 Jess Garms CLA 2007-03-28 19:01:12 EDT
The optional tag does indeed fix the problem for APT, thanks!

Other compilation participants might not know how to fix this though. Two options I can think of to deal with this:

1) add a call to update the classpath in case a participant fixes it, or
2) document in the compilation participant API that they can use the optional tag on a classpath entry if they run into this case (a folder they create for generated files)

APT is fine with #2, since that's what we're doing. It's also easier. ;)
Comment 7 Kent Johnson CLA 2007-03-29 10:12:39 EDT
I'll update the spec to indicate that additional source folders should be tagged as optional.
Comment 8 Kent Johnson CLA 2007-03-29 11:02:54 EDT
Updated the spec.

Released for 3.3M7
Comment 9 Olivier Thomann CLA 2007-04-27 21:10:30 EDT
Verified for 3.3M7