how to refresh eclipse workspace programmatically?
Asked Answered
D

2

20

I am new in eclipse plugin development. I want to refresh my workspace or complete Eclipse programmatically . so is there any to refresh eclipse programmatically.

Digestible answered 29/3, 2011 at 4:30 Comment(4)
This can help you.Archfiend
@Harry Joy : thanks it's exactly what i needed, refresh eclipse within ant script.Erlina
Possible duplicate of Refresh an Eclipse project with AntMalar
If it's just about ant: You may not even have to program anything: Several kinds of launch configurations, including those for Ant Build, have a tab Refresh that lets you select what exactly should be refreshed after completion.Vaish
F
21

Use the IResource.refreshLocal() API. 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.

Fenelia answered 29/3, 2011 at 5:31 Comment(1)
I get IllegalStateException that the workspace is closed. How to solve this problem?Sumo
M
7

Here is a quick snippet to refresh each project in the Eclipse workspace.

for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()){
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
Mashe answered 24/2, 2016 at 22:45 Comment(2)
I get IllegalStateException that the workspace is closed. How to solve this problem?Sumo
Could be a few things. Are you running Eclipse in a headless way by chance? If so make sure you've actually made a workspace. Also check your plugin manifest settings, try reading this post: #962864Mashe

© 2022 - 2024 — McMap. All rights reserved.