Refreshing eclipse-project at the end of a maven build - eclipse

Is there a possibility to refresh the files and folders of a project within eclipse at the end of a maven build automatically.
Usually I'm building from commandline. After a build e. g. the target folder should be refreshed.
Additional info: the maven build runs in the command line and eclipse should update automatically when it ended.

Use Run as -> Maven build... In the run configuration/build properties go to the refresh tab and select the refresh option you want.
Note that the eclipse build and the maven build may interfere, so make sure that you turn off the Build automatically option in the Project menu before staring the maven build. You may get indeterministic compilation errors otherwise.
Here is an eclipse plugin that implements the external hook for refreshing: https://github.com/andrask/maven-eclipse-control-plugin

I dont think so, there is no option to link the two things.
But eclipse has an option Refresh on access which might be useful for you.

For me, the accepted answer of using Run as -> Maven build... and the Refresh option did not refresh the target folder in Eclipse. I needed to do the following:
Preferences -> General -> Workspace -> Refresh using native hooks or polling
When enabled, any changes made by external editors will be automatically discovered by the Workbench. On some systems there may be a slight delay if polling is used.

Related

Where is the "Refresh Automatically" option in Eclipse Kepler for Mac?

My Java project uses JRuby. The Ruby files I execute are resources within the project. I modify those files with an external editor (TextMate). Before I run the project, I need to refresh it. I was looking for a way to have the resources automatically refreshed whenever I run the project, with Eclipse Kepler on Mac:
How do I configure eclipse to automatically refresh a project as part of it's build?
The answer is Window->Preferences->General->Workspace and check "Refresh automatically". However, there is no such thing as "Refresh automatically":
None of the checked options do what I was expecting.
Can Eclipse refresh resources automatically?
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'.
No, that's not true. I run my project (without refreshing it) and Eclipse certainly did not refresh the resources.
A single click on a project, a CTRL+A to select everything, and an F5
should do exactly what you need - refresh everything.
That's what I've been doing. I wouldn't call that "automatic".
Eclipse 'refresh automatically' and Maven build interference
I recently configured Eclipse (ver. 3.6) in order to make it
automatically refresh projects in the workspace (Windows > Preferences > General > Workspace > Refresh Automatically).
What is this mythical "Refresh Automatically" everybody is talking about?
The option was renamed to Refresh using native hooks or polling which is on the Preference page you show.
On the Mac I believe it using polling - so there will be a background thread periodically checking for updates.

Maven install fired during Eclipse build

Lately, I've noticed that whenever I run a build in Eclipse also the maven-install-plugin is fired (copying the jars in my machine local artifacts repository).
I also tried to exclude it from the Eclipse build with org.eclipse.m2e:lifecycle-mapping plugin but nothing changed.
Is that the standard behavior (that I honestly never realized) or is it my fault?
Stefano
This definitely isn't standard behaviour. See How to interpret the Lifecycle Mapping Dialog Box in M2E? for more details on how to interpret the mapping.
This is not standard behaviour. Is it possible that this workspace has "install" defined under Window -> Preferences -> Maven -> "Goals to run when updating project configuration"? This setting defaults to "process-resources"

Ant task to refresh IvyDE Eclipse libraries

I use Ivy for dependency management with the IvyDE Eclipse plugin and I have dependent libraries that change quite frequently and Eclipse doesn't seem to refresh the libraries when I refresh the workspace.
<eclipse.refreshLocal depth="*" resource="/" />
Is there a way to get eclipse to refresh the Ivy libraries using an ant task, or refresh them upon a workspace refresh?
You could try to touch the ivy.xml.
This might trigger an update of ivy after a workspace refresh.
You can go in the Windows -> Preference -> on Eclipse Startup and change to Trigger Refresh
Can't you use Refresh or Resolve on the right-click menu for the "ivy.xml" Eclipse Library in the project?
To add to oers' answer and Pat B's answer above, you would need to go to Window > Preferences > Ivy, and change the following preferences:
Set "On Eclipse startup" to "Trigger resolve", and
Set "On Ivy File Change" to "Trigger resolve"
These should do the trick, especially in combination with the "touch" suggestion that oers made in his answer.

eclipse debugger: attaching source-code of maven dependencies?

I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.
However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...
How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...
Looks like issue MNGECLIPSE-983
I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big .m2/repository tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.
I have since discovered that this problem only occurs if the server is launched using a launch configuration.
The problem does not occur if the server is started by:
click the server icon in the toolbar -> context menu appears
mouse over the intended server -> submenu appears
click on "Start"
While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.
Please do the following steps in Eclipse IDE(Tested with Version: 3.5.2),
In Package Explorer, Right Click on the Project which integrated with Maven container.
Select Maven 2 and then select "Fetch Source JARs".
The above action wil fetch sources of all the 3rd party jars present in the Maven Classpath.
Regards,
Rajesh.
Just put the .m2/repository/ folder itself with the search subfolders option.

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