Bug 352131 - [patch] Ant builder not called after a clean
Summary: [patch] Ant builder not called after a clean
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
: 200204 (view as bug list)
Depends on: 306746
Blocks:
  Show dependency tree
 
Reported: 2011-07-14 12:24 EDT by Jean-Philippe Gariepy CLA
Modified: 2020-08-10 19:13 EDT (History)
14 users (show)

See Also:


Attachments
a sample project exhibiting the problem (2.66 KB, application/x-zip)
2011-07-14 12:25 EDT, Jean-Philippe Gariepy CLA
no flags Details
Proposed patch (3.70 KB, patch)
2012-01-13 01:26 EST, Satyam Kandula CLA
no flags Details | Diff
Patch in consideration (11.53 KB, patch)
2012-01-16 12:26 EST, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Philippe Gariepy CLA 2011-07-14 12:24:53 EDT
Build Identifier: 20110615-0604

Eclipse doesn't invoke Ant builder after a clean even if the builder is configured accordingly.

Note: Project->Build Automatically is checked.

Reproducible: Always

Steps to Reproduce:
1. Import sample project (attached)
2. Open the Console view
3. Invoke Project->Clean... and select the "test-bug-ant-build-trigger" project
4. The console doesn't show the message from the script.
Comment 1 Jean-Philippe Gariepy CLA 2011-07-14 12:25:49 EDT
Created attachment 199681 [details]
a sample project exhibiting the problem
Comment 2 Michael Rennie CLA 2011-07-18 11:35:32 EDT
*** Bug 351744 has been marked as a duplicate of this bug. ***
Comment 3 Michael Rennie CLA 2011-07-18 12:09:58 EDT
*** Bug 200204 has been marked as a duplicate of this bug. ***
Comment 4 Beads Land-Trujillo CLA 2011-07-18 12:55:51 EDT
(In reply to comment #2)
> *** Bug 351744 has been marked as a duplicate of this bug. ***

Not related.  Ant is invoked under bug 351744.  Invoking Ant throws a Java exception that hangs Eclipse operation.  If Ant weren't invoked, there'd be no error complaining that a main class couldn't be found for Ant.
Comment 5 Satyam Kandula CLA 2011-10-20 07:43:28 EDT
'After a "Clean"' in the Targets tab really means "Before a build which happens after a clean". We need to change the wording.
Comment 6 Jean-Philippe Gariepy CLA 2011-10-20 09:13:07 EDT
(In reply to comment #5)
> 'After a "Clean"' in the Targets tab really means "Before a build which happens
> after a clean". We need to change the wording.

Agreed but the problem remains.
Comment 7 Satyam Kandula CLA 2012-01-02 06:04:20 EST
(In reply to comment #6)
The behavior has changed because of the change in the way the build is getting trigged from platform/resources. Look at bug 306746. We need to see what is the best way to go for ant builder.
Comment 8 Satyam Kandula CLA 2012-01-13 01:26:31 EST
Created attachment 209428 [details]
Proposed patch

Patch to fix this issue. Added the trigger even for AUTO_BUILD and when the build is called, the build is filtered off if it is not really full build. 
I haven't written tests yet for this. I will do so.
There is one issue with this patch. For the existing builders to work, one has to go to the UI, look at the targets and click OK.
Comment 9 Satyam Kandula CLA 2012-01-16 12:26:18 EST
Created attachment 209568 [details]
Patch in consideration

This patch also tries to migrate the old builders. There are still no tests added.
Comment 10 Markus Keller CLA 2012-01-25 15:16:26 EST
Do we really need migration for old builders?

Doing this silently behind the scenes when the user edits a builder and then clicks OK doesn't sound right. There's no visible change in the UI, and the change in the .launch file is this additional line:
<intAttribute key="org.eclipse.ui.externaltools.ATTR_VERSION" value="1"/>

That's very confusing. The expected behavior should just work out of the box, without any configuration change.

Bug 340864 has recently documented the expected behavior, and that matches the expectation in comment 0:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-93a_project_builder_targets.htm
Comment 11 Satyam Kandula CLA 2012-01-26 22:57:02 EST
(In reply to comment #10)
> Bug 340864 has recently documented the expected behavior, and that matches the
> expectation in comment 0:
> http://help.eclipse.org/indigo/index.jsp? topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-93a_project_builder_targets.htm

The documentation says 'After clean' will trigger the builder irrespective of the 'Build Automatically' status. However, with the change in bug 306746, this no longer works. 

> Do we really need migration for old builders?
To fix this, this builder has to be registered for 'auto build' too. That way the new builders can be fixed, but the old builders have to be migrated to support this :(. 

> 
> Doing this silently behind the scenes when the user edits a builder and then
> clicks OK doesn't sound right. There's no visible change in the UI, and the
> change in the .launch file is this additional line:
> <intAttribute key="org.eclipse.ui.externaltools.ATTR_VERSION" value="1"/>
> 
> That's very confusing. The expected behavior should just work out of the box,
> without any configuration change.

The real change actually goes into the .project file with the builder's getting registered for auto too. The version number is being stored to avoid checking every time. Migration of the launch configuration can actually be avoided, but the .project file will have to get updated :(.
Comment 12 Markus Keller CLA 2012-01-27 13:34:58 EST
Oh, I missed the builder changes in .project.

So bug 306746 was in fact a breaking change that has not been mentioned in the migration guide for 3.7.

Unless bug 306746 gets reverted and fixed in a compatible way, I guess the Ant support indeed doesn't have another choice than to migrate existing builders.
Comment 13 James Blackburn CLA 2012-01-27 16:30:22 EST
(In reply to comment #12)
> Unless bug 306746 gets reverted and fixed in a compatible way, I guess the Ant
> support indeed doesn't have another choice than to migrate existing builders.

An alternative would be to simply fix the CleanDialog as proposed in patch 1 on the bug, to prompt the user to rebuild the cleaned projects:
https://bugs.eclipse.org/bugs/attachment.cgi?id=162699

This is both easy, safe, and gives the user full control.  (There was some pushback against this, instead a request was made to make the dialog more featureful, which hasn't happened.)
Comment 14 Massimo Roscio CLA 2012-02-22 08:47:36 EST
Observed same behaviour, from time to time, with
Version: 3.6.2
Build id: M20110210-1200
on Windows XP.

Currently stuck into this problem with a project.
Cleanup performed when upgrading compiler compliance level from 1.5 to 1.6.
Needing help.
regards
Comment 15 Massimo Roscio CLA 2012-02-22 08:54:57 EST
Fixed account details.
Massimo Roscio
Milano, Italy
Comment 16 M Stevens CLA 2013-06-12 10:31:32 EDT
Hello,
This problem still remains in Juno SR2. This is very annoying...

Situation (from my "user" point of view):
-----------------------------------------
I'm using an Ant script to generate an additional Java file. The class in this file is reference by the rest of my project. This generated file is deleted upon clean (and it should be).
The consequence is that after a clean the whole subsequent build fails because the generated file is absent because (due to the BUG) Eclipse does not call my Ant builder after the Clean (even though it is set up as such).

One possible work-around I tried is to make the Ant builder also run upon Auto builds. However, this causes an endless building loop because my Ant builder is also set up to make refresh the project folder. Which means the auto build is retriggered due to the newly generated file.

A work-around which does work, but is highly counter-intuitive is to make my Ant script run DURING the clean. Which causes my file to be regenerated right after it was deleted by the clean operation.

Given that bug is almost 2 years old I truly hope it will be fixed in new Eclipse release in the near future.
Comment 17 M Stevens CLA 2013-06-12 10:37:07 EDT
Correction: the 2nd work-around I mentioned only works every 2nd time!

Please fix the bug in Eclipse itself or post a working work-around for users...
Comment 18 Glenn Burkhardt CLA 2018-08-01 08:33:49 EDT
I just tried the sample project with Photon Release (4.8.0), and as far as I can tell, the problem still exists.  We also have an external builder that's not running after a clean.  It's not an Ant builder, but simply runs a Bash script.

This appears to be a recurring problem:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=87697
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206540

and it would help our work if it were fixed.
Comment 19 Andrey Loskutov CLA 2018-08-01 08:49:38 EDT
(In reply to Glenn Burkhardt from comment #18)
> I just tried the sample project with Photon Release (4.8.0), and as far as I
> can tell, the problem still exists.  We also have an external builder that's
> not running after a clean.  It's not an Ant builder, but simply runs a Bash
> script.
> 
> This appears to be a recurring problem:
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=87697
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=206540
> 
> and it would help our work if it were fixed.

If you need the fix, the best thing you can do is to provide a patch. See https://wiki.eclipse.org/Platform_UI/How_to_Contribute
Comment 20 Eclipse Genie CLA 2020-08-10 19:13:55 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.