I'm developing a plug-in for Eclipse Luna and it allows users to create custom projects and use ant to build them. I use ant view in eclipse to list all available targets and to execute them. The problem is when I execute any target that creates some folders and files in project directory the project inside eclipse package explorer isn't updated so the user can't see newly created files. Is it possible to refresh the project somehow?
So far I found this way of refreshing projects:
IProject project = root.getProject(currentProjectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
But the problem with it is I don't know where to call it from. How would I add some listener or action when target in ant view is clicked? Or is there maybe a way to refresh project directly from ant(I think this is not likely but it's worth a shot)?
Eclipse does provide an Ant task to do a refresh:
<eclipse.refreshLocal resource="MyProject/MyFolder" depth="infinite"/>
But note that this only works when the JRE is set to 'Run in the same JRE as the workspace'
For more details see the help here