Eclipse workspace directory messed up

Hello everyone, I have a problem with the eclipse plugin, every time I run “gradle eclipse” the workspace directory gets messed up and I cannot work with the java classes anymore. There are now multiple directories of the same folder in the workspace. The outcome is fine, and there is actually no problem with the build itself, but I cannot run the classes in Eclipse anymore and that makes things a bit complicated… I first saw this ‘!’ when I upgraded from milestone 6 to 7 and now I upgraded to milestone 8 and deleted the cache.

I appreciate any help! Thanks in advance!

It seems that your src folder is not correctly defined in your .classpath file. Did you modify the source directories of your project within eclipse or within your build.gradle file?

Remember the different syntax on adding a directory to your sourceSet and replacing them:

Replacing the default directory:

sourceSets {
   main {
     java.srcDirs = ['src']
 //overwrites the directory
   }
 }

Adding another source directory to the existing default one:

sourceSets {
   main {
     java.srcDirs 'src'
 //adding the src directory
   }
 }

regards, René

My build script just consists of:

apply plugin: ‘eclipse’ apply plugin: ‘java’

sourceSets {

main {

java.srcDirs = [‘src’]

}

}

jar {

manifest {

attributes ‘Main-Class’: ‘main.java.Game’

} }

Did I miss something?

Every time I want to import another Gradle Build, I get the same error. I have two different versions of Eclipse and both of them have the same issue…

The “problem view” of your eclipse will give you detailed information about what’s wrong in your project setup. I guess it is complaining about the combination of your source directory for java (src) and the resources directory (which is considered by eclipse as an source directory as well) that points to src/main/resources. The combination where one source set folder is nested in another will always cause trouble. In your setup, I would suggest to configure the main/resources folder to be “src” too:

main {
     java.srcDirs = ['src']
      resources {
       srcDirs = ['src']
     }
   }

regards, René

Sorry it still doesn’t work, still looks the same… But it worked until milestone 6 without any problems. I am using Homebrew to install Gradle. I deleted the old cache of milestone 6 and 7 in .gradle/cache/ did I forget something after migrating to Milestone 8?

Can you please give “gradle cleanEclipse eclipse” to be sure that alle eclipse project files are generated from the scratch? deleting any ./gradle/cache isn’t necessary here in my opinion. What is eclipse “problem view” complaining about?

regards, René

Thank you very much, the gradle cleanEclipse solved the problem combined with the code from above:

main {

java.srcDirs = [‘src’]

resources {

srcDirs = [‘src’]

}

}

Thanks again, very helpful!