Tools and Technologies used in this article :

  1. Spring Tool Suite 3.2

  2. JDK 7

 

eclipse.refreshLocal is Eclipse Platform provided ant task to refresh a specific folder in the workspace.

eclipse.refreshLocal

This task is a wrapper to the IResource.refreshLocal() method. Example:

<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

 

Problem

To reproduce the problem, I have written one build.xml file and included eclipse.refreshLocal Ant task to refresh 'src' folder of the dummy project called 'MyProject'.

File : build.xml Overall project structure
Overall project structure

Now, if we execute the Ant build script then it'll be failed with following message

Console

 

Why?

By default, Ant runs in a VM which is different from the VM where Eclipse is already running. As a result, it is not aware of the Eclipse Platform and fails to create that particular task.

 

Solution

Run Ant inside the same VM where Eclipse workspace is running.

 

How?

Right click on 'build.xml' and from context menu Run As --> Ant Build...

Run As --> Ant Build...

Go to JRE tab. Select Run in the same JRE as the workspace radio button. Click Run button.

Run in the same JRE as the workspace

This time Ant build will be successful.

Console

We can configure Ant to Run in the same JRE as the workspace using External Tools Configurations... dialog as well.

Run As --> External Tools Configurations...
External Tools Configurations...
Run in the same JRE as the workspace

 

Download SrcCodes

MyProject: GitHub or zip

 

References