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

Bug 311763

Summary: IncrementalProjectBuilder.FULL_BUILD is misleading for some builders like CDT
Product: [Eclipse Project] Platform Reporter: Andrew Gvozdev <angvoz.dev>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jamesblackburn+eclipse
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
patch none

Description Andrew Gvozdev CLA 2010-05-05 12:21:06 EDT
There is a confusion in CDT world what IncrementalProjectBuilder.FULL_BUILD really means stemming from the JavaDoc:
>	 * Build kind constant (value 6) indicating a full build request.  A full
>	 * build discards all previously built state and builds all resources again.
>	 * Resource deltas are not applicable for this kind of build.
>	public static final int FULL_BUILD = 6;
This may be true for Java builder but is not accurate for builders which are capable to manage their build state themselves like make utility called by CDT builder. It is (very significant in big projects) waste of time for those builders to re-build all resources as instructed and facilitated by misleading documentation.

What I am requesting is to update the JavaDoc to fit workflow for such builders. 

To demonstrate the confusion, let me copy here bug 71408 c#9:

I want to mention that bug 70554 comment#13 is at odds with other available sources of information. According to http://www.eclipse.org/articles/Article-Builders/builders.html Project Builders and Natures:
> CLEAN_BUILD: Builders should implement clean by deleting all output files produced by the build
and
> FULL_BUILD: Full Build is a request to discard all existing built state and start over from scratch
Following these definitions, CDT has implemented CLEAN_BUILD as "make clean" and FULL_BUILD as "make clean" (to discard the build state which is managed by make utility) + "make all". As bug 70554 comment#12 describes in scenarios when user manually cleans his project and later on does the build "make clean" happens twice unnecessarily.
bug 70554 comment#13 states:
> FULL_BUILD in Eclipse 3.0 really means "the first build after a "clean". Thus, if you are adding a free "clean" in the implementation of FULL_BUILD, you will always get the duplication of cleaning.
Is it official definition of FULL_BUILD and can we rely on that? If it is true, from the point of view of an implementer of a builder, the article and JavaDoc in IncrementalBuilder.FULL_BUILD are misleading/inaccurate as they mandate a builder to discard the build state which is according to John is unnecessary.

Also, bug 311235 c#13 gives my understanding of this flag from CDT perspective.
Comment 1 Andrew Gvozdev CLA 2010-05-05 12:23:46 EDT
Created attachment 167169 [details]
patch

Here is a patch with the suggested wording. I hope for a review and even more accurate description is appreciated.
Comment 2 Andrew Gvozdev CLA 2010-05-05 12:29:55 EDT
Let me also copy the suggested wording in a comment:

* Build kind constant (value 6) indicating a build request when resource
* delta is not known. On this request all previously built state for the
* purpose of incremental builds is discarded and resource delta is invalidated.
* Incremental builders which rely on platform to track resource changes
* treat this request as request to build all resources again from scratch.
* 
* @see IProject#build(int, IProgressMonitor)
* @see IProject#build(int, String, Map, IProgressMonitor)
public static final int FULL_BUILD = 6;
Comment 3 James Blackburn CLA 2010-05-05 12:56:49 EDT
There are two contexts in which a build kind is used Andrew. I think you've only looked at the first.

1) An IncrementalProjectBuilder receives a build kind as part of the build call
2) An API user calls IProject#build(kind, ...)

In the first case, kind == FULL_BUILD if there is no delta from the build manager, or an API user called #build(FULL_BUILD,...).  Builders which rely on this delta need to build from scratch.

There's no UI for users to directly call FULL_BUILD, but if an API user calls this, the platform forgets the delta which leads to a completely fresh build from behaving builders.

As a result the API is confusing, and the JavaDoc deliberately unclear, because it's used in two contexts with subtly different semantics.

As there's an explicit CLEAN_BUILD kind, it would be good if the API was clear on what API users should do, and what Builders can expect.

An approache might be to:
  1) Request that API users don't call FULL_BUILD (which behaves differently with different builders) rather do an explicit CLEAN_BUILD followed by INCREMENTAL_BUILD
  2) For a builder kind is only FULL_BUILD iff #getDelta() == null (as it is today)

As it stands, you're right there isn't an intuitive difference between FULL and INCREMENTAL, and it only make sense by looking at the implementation...
Comment 4 Andrew Gvozdev CLA 2010-05-05 13:48:36 EDT
(In reply to comment #3)
> An approache might be to:
> 1) Request that API users don't call FULL_BUILD (which behaves differently
> with different builders) rather do an explicit CLEAN_BUILD followed by
> INCREMENTAL_BUILD
It looks to me that FULL_BUILD != CLEAN_BUILD + INCREMENTAL_BUILD. Some builders may be capable to rebuild all resources without cleaning. In this case extra CLEAN_BUILD would result in inefficient processing at the very least. Also, what delta would be supplied on the incremental build? Wouldn't the platform convert it to FULL_BUILD again?
Comment 5 James Blackburn CLA 2010-05-05 13:59:17 EDT
(In reply to comment #4)
> It looks to me that FULL_BUILD != CLEAN_BUILD + INCREMENTAL_BUILD. Some
> builders may be capable to rebuild all resources without cleaning. In this case
> extra CLEAN_BUILD would result in inefficient processing at the very least.

The current _definition_ of FULL_BUILD is that every resource is rebuilt: "A full build discards all previously built state". 
 
Existing builders which expect FULL_BUILD to mean that (and follow the JavaDoc) will treat it as a CLEAN followed by INCREMENTAL, as CDT does - or, put another way, will re-compile every source file irrespective of whether a derived file already exists with a newer timestamp.

> Also, what delta would be supplied on the incremental build? Wouldn't the
> platform convert it to FULL_BUILD again?

None. Yes the current platform implementation would promote INCREMENTAL to FULL, but that's an implementation detail.  Note that an incremental build, having removed all derived resources after a clean, is a full build.
Comment 6 James Blackburn CLA 2010-05-05 14:06:14 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > It looks to me that FULL_BUILD != CLEAN_BUILD + INCREMENTAL_BUILD. Some
> > builders may be capable to rebuild all resources without cleaning. In this case
> > extra CLEAN_BUILD would result in inefficient processing at the very least.

The point I was trying to make is that you can't just re-write the API to say something different and incompatible to what it says today.  Any API caller which explicitly requests FULL_BUILD might expect every resource to be rebuilt.  This won't work with builders that ignore this.

For CDT builders it's neither here-nor-there, as we might deem it too expensive and just ignore the FULL_BUILD request and treat it as incremental. 

I was just pointing out that if the API doc is to be changed, it should be made clear to an API user what  they need to do to fully rebuild a project.  The only sensible way (and what the UI does) is to do a CLEAN followed by INCREMENTAL, rather than calling project.build(FULL_BUILD,...).
Comment 7 Andrew Gvozdev CLA 2010-05-05 14:33:31 EDT
I think that the JavaDoc need to be honest about what the platform itself does and leave the builder behavior to builders. CDT builders do have a need for more sophisticated behavior then the platform could possibly prescribe. They would build a specific configuration or a set of configurations. MakeTarget builder could build a not related target. FULL_BUILD event just discards build state for the current CDT configuration but doesn't for others. The current API documentation as well just misleads API callers on relying on things some builders won't do.
Comment 8 Eclipse Webmaster CLA 2019-09-06 15:35:42 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.

If you have further information on the current state of the bug, please add it. 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.
Comment 9 Eclipse Genie CLA 2021-09-16 01:22:26 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.