Problem: failed to create task or type eclipse.refreshLocal
Eclipse platform provides different useful Ant tasks to interact with the workspace. If you have added any such Ant task (say eclipse.refreshLocal) in your ant build script and started getting "Problem: failed to create task or type eclipse.refreshLocal. Cause: The name is undefined.", then this is the post worth looking into.
Tools and Technologies used in this article :
eclipse.refreshLocal is Eclipse Platform provided ant task to refresh a specific folder in the workspace.
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
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
Now, if we execute the Ant build script then it'll be failed with following messageConsole
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.
Run Ant inside the same VM where Eclipse workspace is running.
Right click on 'build.xml' and from context menu Run As --> Ant Build...
Go to JRE tab. Select Run in the same JRE as the workspace radio button. Click Run button.
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.