Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 87697 - External builder is not invoked after clean
Summary: External builder is not invoked after clean
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M7   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-10 14:40 EST by Vlad Kasyanenko CLA
Modified: 2018-08-01 08:49 EDT (History)
2 users (show)

See Also:


Attachments
Patch to BuildManager.java (1.55 KB, patch)
2005-03-11 14:12 EST, John Arthorne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad Kasyanenko CLA 2005-03-10 14:40:51 EST
I have a number of Ant builders configured to be invoked on "After a Clean" 
builds, on manual builds, and on auto builds. They used to work fine with 
previous versions of Eclipse (not sure though what was the latest version that 
I tried), but with Eclipse 3.1M5a "After a Clean" option does not work.

Example 1:
I have a builder that deletes all files/folders from some area. It does not 
have any resources associated with it because the sole purpose of that builder 
is to perform some clean-up. It is configured to be invoked after clean 
(Project -> Properties -> <my builder> -> Edit… -> Targets -> After a “Clean”), 
but in such configuration it is never invoked. If I change configuration to 
invoke it during a clean, then it is invoked just fine.

Example 2:
I have a builder that creates a JAR file from the associated resource set and 
copies it to some folder. It is works just fine on manual and auto builds, but 
is not invoked on “After a Clean” build. The only way I managed it to be 
invoked on “After a Clean” build was:
- Uncheck auto build option for a project.
- Modify a file from associated resource set.
- Clean up the project.
In this case my builder is invoked, but in all others it is not (and fact that 
resource set is not dirty should not prevent it from being invoked on “After a 
Clean” build).
Comment 1 Darin Swanson CLA 2005-03-10 19:24:23 EST
This is what I see:

If "build automatically" is turned on and a clean is performed, the build that 
occurs after the clean is not indicated as an "after a clean" build but rather 
as an "autobuild" build.

If "build automatically" is turned off and a clean is performed with "Start a 
build immediately" from the Clean dialog, then the build that occurs after the 
clean is indicated to be an "after a clean" build.

CC John for comment. 
It appears to me that the external tool builders are correctly responding to 
the triggers but the triggers may not be what the users expect.
Comment 2 John Arthorne CLA 2005-03-11 10:51:10 EST
Remind me why we allow configuration of the targets for "after a clean" in
addition to "during a clean"?  I recall we did this because we took away the UI
for invoking a full build in 3.0, and "after a clean" was the new name for "full
build" on this page.  However, now that we allow configuration of the target for
clean, the option for "after a clean" seems redundant. Perhaps this should just
be removed, leaving only "clean", "manual build", and "auto build"?
Comment 3 John Arthorne CLA 2005-03-11 11:21:08 EST
I will investigate why the behaviour is different when autobuild is on.
Comment 4 John Arthorne CLA 2005-03-11 14:10:33 EST
This is caused by a problem in the platform builder infrastructure. 

To support the "after a clean" case, we currently munge the build trigger as
follows:

int trigger = .... original build trigger
if (trigger != CLEAN_BUILD && builder.lastBuildTree() == null)
  trigger = FULL_BUILD;

I.e., after a clean, the builder's "tree state" will be null because it is
discarded by the clean build.  When this happens we slam the build trigger to be
a full build.  The problem is that we currently do this munging *after* checking
if the build command responds to the given trigger.  Thus the ant builder is
never run, because it only responds to FULL_BUILD, but at the time we do the
check, we haven't yet changed the trigger.

I could move the trigger munging to be done before checking if the command
responds to the trigger, but that requires instantiating the builder.  That
would result in builders being instantiated for no reason if the trigger
filtering decided that no build was necessary.

In short, supporting the "after a build" trigger (aka full build) was a bit of a
hack to begin with, and is now causing more problems (see also bug 71408).  

Darin, can you give some more thought to whether "after a clean" and "during a
clean" are both still needed?  Vlad, feel free to comment if you have cases
where this is important - i.e., does everything work if you just move your
"after a clean" targets to the "during a clean" section?  It seems like it would
simply the user experience to just have "clean", "manual build", and "auto
build" trigger options.
Comment 5 John Arthorne CLA 2005-03-11 14:12:15 EST
Created attachment 18708 [details]
Patch to BuildManager.java

If we decide it is necessary, this patch fixes the reported bug, but has the
sideeffect that builders will be instantiated even if they do not respond to
the specified build trigger.
Comment 6 Darin Swanson CLA 2005-03-11 14:28:54 EST
Thanks John. I will post a comment in bug 63685 and the platform ant mailing 
list to get more community feedback.

If we reduce the set to Clean, Manual, Auto:
The user turns off auto build
The user initiates a clean which is set to cause a build immediately
Then the builders that are set to manual must also be set to respond to full to 
get the build for this case.
Likely what the user expects and I agree it is less confusing and more 
consistent with commandline building
Comment 7 Vlad Kasyanenko CLA 2005-03-11 14:32:23 EST
I do not think that "after a clean" option is redundant (though I do not know 
implementation details).
Here are my observations:
My builder from example 1 works just fine if I invoke it on a clean instead of 
after a clean. But it is very special type of builder, it only performs some 
clean-up and has no recourse set associated with it, therefore during a clean 
is actually even more logical choice for that builder than after a clean.
Builder from example 2 (the one that builds JAR file from some resource set), 
if invoked during a clean builds an empty JAR file (because classes that are 
supposed to be there are not compiled yet by default Java builder). Note that 
eventually result is the desired one, because that builder is also invoked 
after Java builder compiles all classes (not sure what triggers that, probably 
the fact that it is also set to be built on auto and on manual builds).
So, the summary is that builder is invoked twice, once with not desired result 
(empty JAR file), and finally with desired one (correct JAR file). Though it 
can work as a workaround, not sure that it is a real solution to that issue. 
Comment 8 Darin Swanson CLA 2005-03-11 14:40:59 EST
Thanks Vlad.
For you builder 2 case. If we changed the implementation so that a builder set 
to occur on a manual build was executed after a clean occurred (when auto build 
was off) it appears to me this is the behavior you desire?
Comment 9 Vlad Kasyanenko CLA 2005-03-11 15:04:45 EST
Sorry you kind of lost me here - I'm not sure whether to answer yes or no on 
your question...
The desire is that builder should be invoked in 3 cases:
1) On auto build (only if associated resource set is dirty)
2) On manual build (only if associated resource set is dirty)
Those 2 works fine now.
3) On full build (when whole project is rebuilt). Logically full build sounds 
to be "after a clean", but name is not important, what important is that the 
builder should be invoked after the default Java Builder done with rebuilding a 
project. Techincally it might be invoked that way now when using "during a 
clean" option, but, apparently, default Java Builder is configured to run in 
the background (which as I understand corresponds to be launched in a separate 
thread), and I did not find a way neither to change it, or to configure my 
builder to depend on completion of default Java Builder, that's why I'm getting 
that empty JAR file built first time when my builder is invoked.
So what I really need is a way to invoke my builder after default Java Builder 
is done with its job.
Comment 10 John Arthorne CLA 2005-04-01 13:52:54 EST
Darin, did you get any other feedback on the proposed change described in bug
63685 comment 20?  Building after a clean is currently still broken so we'll
need to resolve this either way soon.  Either we remove the "after a clean"
target, or I will need to release my patch from comment #5.  I'm marking this
for M7 so I remember that this needs to be resolved.
Comment 11 Darin Swanson CLA 2005-04-02 11:11:31 EST
Unfortunately the community was silent...
Comment 12 John Arthorne CLA 2005-04-04 12:36:28 EDT
Silence means approval, right? <g>
Comment 13 Vlad Kasyanenko CLA 2005-04-04 12:56:17 EDT
As long as we do not loose previously existed functionality (ability to invoke 
custom builder on a full build without dependencies on resource set changes).
Please keep in mind that with current implementation of “During a clean” I do 
not see a clear way to make builder invoked on a full build (which actually 
occurs after a clean) – see my comment #9.
Please correct me if I am wrong.
Comment 14 John Arthorne CLA 2005-04-27 15:09:21 EDT
Fix released.  I now eagerly instantiate the builder and then check if it
matches the active triggers after doing the munging to handle "after a build". 
This means some builders will be instantiated when they didn't need to, but it
does mean that builders will now run when they are supposed to.
Comment 15 Darin Swanson CLA 2005-04-27 15:15:44 EDT
Good news for me...means I don't have to make any changes :-) Thanks.
Comment 16 John Arthorne CLA 2005-04-27 15:23:11 EDT
Well, as Vlad points out in comment #9, "during a clean" and "after a clean" are
not equivalent.  If you want an external builder to run after the Java builder
has done a full build, you can't hook "during a clean".
Comment 17 Darin Swanson CLA 2005-04-27 15:37:47 EDT
In Ant land doing a clean simply means removing the build artifacts. 

"during a clean" and "after a clean" in my opinion should be two separate 
stages that are not equivalent. 

So expecting "during a clean" to be triggered for "after a clean" (full build 
of builders) does not add up for me.

To get an external tool builder to run after a clean and after the Java 
builder one would configure your external tool builder target(s) for "after a 
clean" and set the builder to be ordered after the Java builder.