Bug 355984 - "Save automatically before build" does not save modified files from referenced projects
Summary: "Save automatically before build" does not save modified files from reference...
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-26 17:10 EDT by Travis Mising name CLA
Modified: 2021-03-02 05:13 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Travis Mising name CLA 2011-08-26 17:10:20 EDT
Build Identifier: 20110615-0604

When I build a project (project1) that references another project (project 2), modified resources within project1 are saved before building.  However, modified resources in project2 are not.

This seems like a minor bug, however it is very annoying to have to manually save all modified files every time I build.  Especially annoying if the modification does not introduce a compile error in which case the non-save is unnoticed.

Reproducible: Always

Steps to Reproduce:
1. Open preferences (Window->Preferences)
2. Disable "Build automatically"
3. Enable "Refresh using native hooks or polling," "refresh on access," and "save automatically before build"
4. Create two java projects (A and B).
5. Create a class in A (AClass) and a class in B (BClass).
6. Set up references between the projects (A references project B).
7. Add a class member to AClass (private BClass member).
8. Modify AClass (don't save) and build project A.  Note that AClass is saved.
9. Modify BClass (don't save) and build project A.  Note that BClass is _not_ saved.  This worked in Helios.
Comment 1 Ayushman Jain CLA 2011-08-27 06:48:53 EDT
Jay, can you please follow up? Seems like a regression over Helios. Thanks!
Comment 2 Jay Arthanareeswaran CLA 2011-08-29 08:13:55 EDT
I see that the preference is mapped to org.eclipse.ui.internal.ide.IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD. Unfortunately I don't have the set-up to see what's wrong. Moving to Platform UI for further investigation.
Comment 3 Lars Vogel CLA 2019-11-14 03:20:10 EST
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.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.
Comment 4 Christian Walther CLA 2020-08-24 07:54:05 EDT
I don’t know about Java projects, but with CDT projects this bug still exists as of Oxygen.3 (yes, I know I’m behind there). It cannot be observed with the "Build project" command because CDT implemented it themselves there in org.eclipse.cdt.internal.ui.cview.BuildGroup.CDTBuildAction.run(), but it occurs when using "Build working set" with a working set that does not include the referenced project.

This seems quite easy to fix (to the point that I was wondering whether it was intentional behavior, which led me to this bug) and I have done it here: https://gitlab.indel.ch/thirdparty/eclipse.platform.ui/-/commit/8c89c1943e3d7121393add3eb94ec25364a71de6

(isBuildReferencedSet() is something I introduced myself in the preceding commit, upstream it is always true.)

No Gerrit for now as I haven’t tested on a current version.
Comment 5 Andrey Loskutov CLA 2020-08-24 07:59:21 EDT
(In reply to Christian Walther from comment #4)
> I don’t know about Java projects, but with CDT projects this bug still
> exists as of Oxygen.3 (yes, I know I’m behind there). It cannot be observed
> with the "Build project" command because CDT implemented it themselves there
> in org.eclipse.cdt.internal.ui.cview.BuildGroup.CDTBuildAction.run(), but it
> occurs when using "Build working set" with a working set that does not
> include the referenced project.
> 
> This seems quite easy to fix (to the point that I was wondering whether it
> was intentional behavior, which led me to this bug) and I have done it here:
> https://gitlab.indel.ch/thirdparty/eclipse.platform.ui/-/commit/
> 8c89c1943e3d7121393add3eb94ec25364a71de6

Please note, your patch is not going to check references of referenced projects :-)

> No Gerrit for now as I haven’t tested on a current version.

Feel free to provide one, once you have everything tested.
Comment 6 Christian Walther CLA 2020-08-24 08:11:20 EDT
(In reply to Andrey Loskutov from comment #5)
> Please note, your patch is not going to check references of referenced
> projects :-)

Good point, I just copied the CDT solution without checking whether IProject.getReferencedProjects() is recursive. I’ll improve that.
Comment 7 Christian Walther CLA 2020-08-27 03:50:18 EDT
In case anyone is interested, here’s the improved version that considers recursive references. It also does it on the build configuration rather than project level - not sure if that adds any value, but it seems more fine-grained. This depends on the assumption that project references entered by the user are automatically translated into build configuration references, which I only checked empirically.

https://gitlab.indel.ch/thirdparty/eclipse.platform.ui/-/compare/efee555b...2c9614a5
Comment 8 Andrey Loskutov CLA 2020-08-27 04:48:57 EDT
(In reply to Christian Walther from comment #7)
> In case anyone is interested, here’s the improved version that considers
> recursive references. It also does it on the build configuration rather than
> project level - not sure if that adds any value, but it seems more
> fine-grained. This depends on the assumption that project references entered
> by the user are automatically translated into build configuration
> references, which I only checked empirically.
> 
> https://gitlab.indel.ch/thirdparty/eclipse.platform.ui/-/compare/efee555b...
> 2c9614a5

Could you please create a Gerrit review with this patch?
Comment 9 Christian Walther CLA 2020-08-27 04:55:57 EDT
I plan to do that once we update our product to a current Eclipse release and I can test it there - or would you like it untested right now? I don’t have time to update my development environment right now.
Comment 10 Andrey Loskutov CLA 2020-08-27 05:15:14 EDT
(In reply to Christian Walther from comment #9)
> I plan to do that once we update our product to a current Eclipse release
> and I can test it there - or would you like it untested right now? I don’t
> have time to update my development environment right now.

Feel free to provide a Gerrit if you are ready. I just assumed the last comment was saying that the right patch is already there.
Comment 11 Kalyan Prasad Tatavarthi CLA 2020-11-18 13:32:19 EST
Moving to 4.19. Feel free to move this bug back to 4.18 if you plan to fix this bug for 4.18.
Comment 12 Sravan Kumar Lakkimsetti CLA 2021-03-02 02:56:42 EST
Removing the target for now.
Comment 13 Christian Walther CLA 2021-03-02 05:00:58 EST
Working on it, but I won’t make it in time for 4.19.
Comment 14 Sravan Kumar Lakkimsetti CLA 2021-03-02 05:13:48 EST
(In reply to Christian Walther from comment #13)
> Working on it, but I won’t make it in time for 4.19.

Please re-target when you are ready.