Ok so to elaborate more on the links I put in the comments.
I stumble upon two ways of doing what you need (didn't actually do them but they seemed to work for others):
1) Refreshing Eclipse Workspace using ANT (Answer Link)
As stated in the link, Eclipse provides several ant tasks that you can use for various purposes, one of which is the <eclipse.refreshLocal />
tag:
<eclipse.refreshLocal resource="MyProject/MyFolder" depth="infinite"/>
- resource is a resource path relative to the workspace
- depth can be one of the following: zero, one or infinite
Furthermore, if you get a BUILD FAILED error, make sure you aren't running ANT outside of the Eclipse JRE. To fix this, go open up the External Tools Dialog (Run > External Tools > Open External Tools Dialog...) and make sure the JRE tab is set to "Run in the same JRE as workspace."
2) Refreshing Eclipse workspace programmatically using the IResource.refreshLocal() API (Answer Link)
As stated in the linked answer, you can do this at project root, a particular folder or an individual file.
To refresh all projects in a workspace, simply enumerate all projects using ResourcesPlugin.getWorkspace().getRoot().getProjects()
API and refresh each in turn.
Here is another example (from the API website) that sets the contents of a file using a FileOutputStream
, and then uses refreshLocal
to synchronize the workspace.
private void externalModify(IFile iFile) throws ... {
java.io.File file = iFile.getLocation().toFile();
FileOutputStream fOut = new FileOutputStream(file);
fOut.write("Written by FileOutputStream".getBytes());
iFile.refreshLocal(IResource.DEPTH_ZERO, null);
}