Eclipse - Galileo IDE force save of changed files before build? - eclipse

When I used previous versions of Eclipse (e.g. Ganymede/Europa) if I had edited a file and then attempted a build Eclipse would prompt me to save first.
Since I updated to Galileo (Build id: 20090920-1017 & just checked for updates) when I build I'm not prompted to save first. Perhaps the dialog had a checkbox for "don't tell me again" which I mistakenly checked on???
I figure it is just a preference setting some where but I can't seem to find it, search in Preferences for 'save' and for 'build' but did not find it. I tried "Save automatically before build" but that actually did not work for me, and isn't really what I was looking for anyways.
Any ideas?
thanks.
Edit: I'm actually using an Ant script to 'build' (right click on script and Run As...Ant Build). So perhaps my original wording was a bit off base since I did not state how I was building.

It's under Window -> Preferences -> General -> Workspace -> Save automatically before build. This works for me if I'm doing an Eclipse build (Project -> Build All). Is that how you're building?

As mention in this thread, the only other options (other than the "Save automatically before build") which actually prompt for the user for file saving are:
> Run/Debug > Launching > Save required dirty editors before launching
> Run/Debug > Launching > [x] Build (if required) before launching

Answer of VonC looks great, but does not work as it seems (Eclipse 3.5.1.R35x_v20090910 on WinXP-Pro-32). However Eclipse and I seem to think differently about what is a "required dirty editor" :-( --
Would be nice if it would be possible to define a scope of resources to check for dirtyness for every single launch configuration -- with "containing project & refernced projects" as the default setting.
But it looks like 3.5.2 fixes this problem.

Related

How to see what triggered "Build workspace" in Eclipse

My eclipse is constantly running "Build Workspace" tasks. It is not a long running builds, more like 1 build a second.
Sometimes I'd see 10 "Build workspace" tasks sleeping and waiting in the Progress tab.
I'd like to know what is triggering those builds. I have many plugins installed.
What is the way to troubleshoot this?
Here are some steps to help you debug what is going on.
Download the Eclipse Classic SDK for whatever version of Eclipse you are currently using. For Juno that link is here.
Open the eclipse.ini for your current normal eclipse and add the following options: -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
Start your Eclipse instance that you want to debug, it should pause at the splash screen
Unzip the Eclipse classic SDK and start that Eclipse instance
Open the Plugins view
Find org.eclipse.core.resources
Right click and select "Add to Java Search"
Open Type dialog, type in "BuildManager"
You should see a class from that plugin be given as an option, then open it
Find the line that looks like: prereqs = currentBuilder.build(trigger, args, monitor); It should be about line 728 (For Eclipse Juno)
Set a breakpoint here
Create a new Remote Java Application debug configuration and point to localhost port 8000
Launch this debug configuration
You should see your other Eclipse instance startup
Now every time the Eclipse build manager fires off a build (which should happen on all of those Build Workspace jobs), then you will see this breakpoint be hit and you can find out what builder is firing.
Update 1
If you need source to other Eclipse bundles they can also be added in the "Plug-ins" view. Select all the plugins there and right-click and use Add to Java Search
What plugins do you have installed that are currently active?
Press CTRL+3 type "plugin" and then choose plugin registry.
In the plugin view right click and choose "Active Only"
Check the non-essential core plugins (for example related to servers which automatically build & publish)
Post a screenshot of active plugins if you need any more help
You may have build automatically checked which will build when you save. Check under the nav Project > Build Automatically
Other way to close all unused projects.
Further, for good view, use filtering: View Menu -> filters -> Check 'Closed Project'.
Sometimes if you have > 20 opened projects you can observe constant 'build workspace' tendency.

Eclipse Indigo "Save Actions" are not being applied

I'm new to Eclipse and downloaded the following version:
Eclipse Java EE IDE for Web Developers.
Version: Indigo Release
Build id: 20110615-0604
[edit] Eclipse Platform Version 3.7
I have edited Java > Editor > Save Actions to do the following: Remove trailing white spaces on all lines, Correct indentation
When I save the .java file, those actions are not applied... is this a bug?
Found this that might be related: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350475
Assuming that this relates to JavaScript files, then the related Eclipse bug could be helpful.
The problem (as I've just experienced) is that you can edit the JavaScript -> Save Actions preferences via the context menu when editing a JavaScript file, but the actions will not be run.
The solution is to right click on the project containing the .js file, and select Configure -> Convert to JavaScript project.
The bad news is that this will then will also enable Eclipse's not-so-great JavaScript validation, therefore telling you that libraries such as moment.min.js are broken.
Well for those of you who have found this topic... I did find 2 solutions, no thanks to Eclipse, other than the fact that it is open source and people can write plugins.
Eclipse Platform Version 3.7
AnyEdit - plugin that does it for you when you Save file (I believe this is what eclipse SHOULD be doing)
Go to: Window > Preferences. Then under General > Keys. Make sure drop down for Scheme: is Default and enter 'remove trailing' in the filter. You should then see "Remove Trailing Whitespace" under the command column. Bind it to your own key command.
The only drawback to #2 is that you have to actually press the key binding while editing the file, kindof like a cleanup action.
Too bad Eclipse hasn't taken the approach that ALL file types should be configurable in this way... sometimes I miss TextPad.
Old question, but at least for newer Eclipse versions there's a better solution: Go to the project properties, then to Project Facets. If it tells you that your project isn't in faceted form yet, then convert it. Afterwards (or if it already was faceted), just enable the JavaScript checkbox.
I had the same issue with Eclipse 4.4 (Luna) and this fixed it for me, the save actions are now executed on save.
Adding to jlh's answer, I also had to configure the JavaScript include path of the project to enable save actions. Before that even a manual "Clean Up ..." from the source menu wouldn't work.

How to configure eclipse to autosave on run?

I'm looking for a configuration or plugin for eclipse that automatically saves files (so I don't have to use Ctrl+S). It could do it on lost focus or over some period of time. I think I saw something like that (I know IDEA has it), but I cant find it now.
Update seven years later (Eclipse Neon 4.6)
Eclipse now has an Automatic Save of dirty editors
The autosave option is disabled by default.
A new autosave preference page (Preferences > General > Editors > Autosave) is available and allows to enable/disable the autosave and change the interval of autosave.
The countdown is reset on keyboard activity, mouse click, or when a popup is displayed (e.g. content assist, preference page, ...).
Original answer (2009)
The OP IAdapter added in the comments:
I bet plugin like I describe exists.
... and you are right!
Eclipse plugin saveDirtyEditor should do just what you need.
Copy the SaveDirtyEditors_1.0.2.jar in your plugin directory.
You will get a new preference page under
General > Editors > Text Editors > Save Dirty Editors
, allowing you to save dirty files like 'myfile.java' under 'myfile.java.snapshot' every 30 seconds (can be less if you want).
Without additional plugin, though, Eclipse does not support natively that feature.
The closest could be:
Window > Preferences > type "build"
> General > Workspace > [x] Save automatically before build
That way, each time you hit CTRL+B for actually building your sources, they would be saved.
But I realize this is not exactly what you are after.
Beware your option would not be very efficient with the "build automatically" option activated... (that would trigger too much builds)
Again, without achieving exactly what you are looking for, you also have:
Run/Debug > Launching > Save required dirty editors before launching
Run/Debug > Launching > [x] Build (if required) before launching
Note: the difference between IntelliJ IDEA and eclipse is the "compile on save" feature:
As mentioned in the IDEA FAQ:
Q:
Can I enable "compile on save" in IntelliJ IDEA?
IntelliJ IDEA currently doesn't support this feature.
However there is an "Eclipse-mode" plug-in which provides similar functionality, so we suggest you to try this plug-in.
Note that by default IntelliJ IDEA saves the files for you, so you don't have to press the Ctrl+S shortcut frequently like you need to do in other IDEs.
However, with Eclipse, the "build on save" is activated by default, hence the absence of that particular feature.
http://code.google.com/p/eclatosa/
"Saves all open editors in eclipse when deactivating the eclipse window (like in IntelliJ)"
No need to install more plugin.
Window -> Preferences -> General -> Workspace
and there you can check:
Save automatically before build + Build automatically
If that doesn't work try this:
Preferences -> Run/Debug -> Launching -> Save dirty editors before launching
I wrote a plugin a long time ago to do this that still seems to work: http://www.stateofflow.com/projects/71/save-me
It saves the editor when it loses focus. However, if you switch away from eclipse it doesn't notice.
Try this
Goto Eclipse Preferences > General > Editors > Autosave
if it not work then try this
Preferences -> Run/Debug -> Launching -> Save dirty editors before launching

Can Eclipse refresh resources automatically?

Eclipse (3.4.2 with PyDev) deals with out-of-sync resources (files that have been edited outside of the IDE) differently from other IDEs that I've used, where only resources with editors open are considered out-of-sync. In Eclipse, any resource can go out of sync.
This means that when I perform a search after any file has changed outside of Eclipse, I get an error dialog telling me that files are out of sync, even if they have no open editors. As far as I can tell, there is no global refresh command, so I'm forced to read the project names (I have several projects) in the error dialog, and do a right-click + refresh for each of them.
I've checked the Refresh Automatically setting in Settings > General > Workspace, but this has no effect. Is there any way to get Eclipse to always just load non-active resources from disk?
This issue will be fixed in Eclipse 3.7 (Indigo). While "Refresh Automatically" does eventually bring resources back into sync, the refresh hook only exists for Windows, so on Linux and Mac OS it has to poll the filesystem periodically.
From 3.7 there's a new preference Settings > General > Workspace > Refresh On Access (aka Lightweight Refresh). This preference causes Eclipse to automatically refresh resources when it discovers that they're 'out-of-sync'. When opening, reading or searching files, it'll prevent out-of-sync errors from occurring.
See also: https://bugs.eclipse.org/303517
I think if you click on the project node in the Project Explorer and press F5 or right click and select Refresh, all resources for that project will be refreshed. Also, if you CTRL+click on multiple projects, you should be able to refresh multiple projects at the same time.
A single click on a project, a CTRL+A to select everything, and an F5 should do exactly what you need - refresh everything.
I'll have to test this when I get the chance, but I believe this is how I overcame similar problems in the past.
I've noticed that this answer routinely is getting down voted. I'd like to point out that the question refers to a specific version of Eclipse: 3.4.2. There was actually no automatic method to refresh out-of-sync resources until version 3.7 Indigo of Eclipse, as mentioned in James Blackburn's answer. The method described in this answer is the only method to achieve this in version 3.4.2 (and any other version before 3.7 Indigo).
Out of synchronization problem is common in eclipse IDE so you have to check this option windows -> preference -> Workspace -> refresh using native hooks or polling.
Eclipse Helios possesses a built in refresh feature at Preferences > General > Workspace. It's in the same spot where you disable automatic builds. Select refresh automatically. A plugin with the same functionality is Andrei Loskutov's Filesync Plugin. The update site address is: http://andrei.gmxhome.de/eclipse/. During installation, select Eclipse 3.5-3.7 plugins > FileSync.
Given that Java 7 has an api for filesystem hooks, one would think that refresh could be handled better in Eclipse.
Edit: Actually, there is a plugin that uses this mechanism: https://github.com/psxpaul/EclipseJava7Refresher
There is a global refresh - have nothing (or everything) selected in the package explorer and press F5 (or right-click on empty space and select Refresh). Of course, this could take rather long if you have large projects.
The global refresh actually exists in plain Eclipse without any plugins and without selecting every project in your workspace.
Basically you need to deselect everything in your project explorer and hit F5. To do that Ctrl+click the selected resource in the project explorer and hit F5.
A global refresh is really missing in Eclipse. The above procedure with selecting all projects and then running refresh (e.g. F5) does not work if you have closed projects included in your selection. This means, if you have 1/2 of your many projects closed as I do, you find yourself manually Ctrl-clicking through your dozens of projects. This is quite painful. I wish Eclipse would simply ignore closed projects.
Perhaps you should add a feature request on the eclipse site:
https://bugs.eclipse.org/bugs/
I think it would be a great idea to add a preference for automatically refreshing out of date resources.
Yes, Refresh on Access is long overdue ... those answers to this and similar enquires usually suggested enabling the global auto-refresh, which could take an age for large remote projects.
In fact there are those who would say that Refresh on Access should have been the original (< 3.x) default behaviour ...
I managed to solve this by creating a new "external tool" run config that executes a blank batch file. In the run config, you can have it refresh the workspace when complete. Then I created a macro using Practically Macro that 1) executes the last external tool run config (refreshing the workspace), then 2) executes the last debug run config (running my app). If you uncheck "Allocate console" then the completed external tool entry won't show up in the debug window.
Even if the solutions proposed by others perso are indeed correct, you have a "Refresh All" plugin for Eclipse. Simply add the Update page to your Eclipse list of update sites to install it in your IDE.
For Starting up there is an option to automatically refresh files in
Window -> Preferences -> General -> Startup and Shutdown -> Refresh workspace on startup
Click it in order to have a "fresh" start in eclipse. :)
Version: Eclipse 4.12

In Eclipse, why does "Build Automatically" get mysteriously disabled?

I'm running Eclipse Europa (3.3). I leave the "Build Automatically" setting, under the Project menu, on all the time. Once in awhile my code isn't compiling, and I puzzle over it and then pull down the Project menu ... lo and behold, it's not set anymore. What gives? Is this a bug, or is there something else I'm doing that could cause it?
Edit: I am running the regular Java developer installation, plus Subversive and its connectors, Jetty Launcher, and I believe no other plugins. Other people at my workplace have had the same problem.
Edit: I am still having this problem once in a blue moon, only now I'm using Eclipse Galileo (3.5) for Windows. I haven't had this problem in Galileo for OS X, neither in Cocoa nor Carbon, but I have not used that for as long.
With Eclipise Mars.1 (4.5.1), Oomph may be the culprit. Eclipse Oomph supports automatically disabling Build Automatically with entries in
On Windows
%USERPROFILE%\.eclipse\org.eclipse.oomph.setup\setups\user.setup
If you want to disable this Oomph behavior try deleting the following setting
"Eclipse->Navigate Menu-> Open Setup menu entry-> Open User menu entry", a Preference Task under "User Preferences -> org.eclipse.core.resources -> description.autobuilding"
I learned about this setting by posting to the Oomph Eclipse Community Forum on Feb 8th, 2016. I posted a question titled "Oomph Defect? Build Automatically Keeps Getting Disabled". Ed Marks replied the same day with details about Oomph's support for managing the Eclipse "Build Automatically" setting.
https://www.eclipse.org/forums/index.php/m/1722751/#msg_1722751
I don't have eclipse right here to test and make sure but here is an idea.
Is any of the project or even workspace file in SVN ? if they are and they were uploaded with auto build disabled that might explain it
You update and overwrite your settings. This doesn't become apparent until you restart eclipse. this would also explain why other people at your workplace experienc this. it would even explain why some don't : thay are the ones who are careful what they update and don't allow eclipse to overwrite their own settings plus the ones who actually prefer to have autobuild disabled :)
I had the same problem and when I looked at the Source tab under Java Build Path (under the menu Project > Properties ) there were some source directories that didn't exist anymore (marked with a red X). After I deleted them, compilation worked fine and all new .class files are under the bin folder.
Strange. Is there perhaps a plugin installed that turns this off without your knowledge?
Maybe there is some conflicting shortcut. For example, some duplicated shortcut may be toggling it.
I am running 3.4 and I also have this mysterious behavior. I had it in 3.3 as well. I use CVS not SVN. Does not seem to follow a pattern just once in a while it gets switched off and then weird confusing stuff happens until I remember to check it and switch it back on. I am almost to the point where I want to write a plugin to always turn it on when eclipse loads.
When installing Google Plugin for Eclipse, 'Google App Engine for Android' is also installed.
For me, I uninstalled 'Google App Engine for Android', which I didn't need, and solved this problem.