How to prevent linked resources in Eclipse?


(Horcrux7) #1

On a “Refresh Gradle Project” Buildship add some sources as linked resources from the build.gradle. Eclipse can not good handle this. Is there an option to prevent this?

(Stefan Oehme) #2

You are probably including source folders that are outside of your project directory. The only way to do that in Eclipse is with linked resources. So if you don’t want them, don’t include external source folders.

I’d be curious what you mean by “does not handle them well”? Linked resources work fine for me.

(Horcrux7) #3

On the continuous build server I need the additional source folders. In Eclipse I does not need it. There are additional Eclipse projects (not Gradle projects)

Many features does not work with linked sources. For example the repository functions. It is not possible to commit, update, see the history on linked resources.

(Horcrux7) #4

So if you don’t want them, don’t include external source folders.

How can I do this in Eclipse? It there a special environment variable to detect that the script run inside Gradle?

(Stefan Oehme) #5

If you don’t need them, then you can remove them from the .project and .classpath like this:

eclipse {
  project.linkedResources = []
  classpath.file.whenMerged {
    entries.removeAll {

(Horcrux7) #6

If I try this then I receive the follow error:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method eclipse() for arguments [build_3195byk41jk6sicx0c4lejdp6$_run_closure10@178caaf] on root project 'CC' of type org.gradle.api.Project.
	at org.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(
	at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(
	at org.gradle.groovy.scripts.BasicScript.methodMissing(
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$

(Stefan Oehme) #7

You need to apply the eclipse plugin to your project.

(Horcrux7) #8

Thank you very much. It works. I have reduce it to:

apply plugin: 'eclipse'
eclipse {
    project.linkedResources = []