I have the following project structure:
- root-gradle (
build.gradle
)- project-group1 (no build file)
- project1 (
build.gradle
) - project2 (
build.gradle
) - ...
- project1 (
- project-group2 (no build file)
- ...
- project-group1 (no build file)
So happens that I have to recreate Eclipse projects often. I run command:
gradle cleanEclipse eclipse
After a number of runs "eclipse" task stops working as expected. Namely, it does not add gradle nature to the projects anymore and does not recognize
sourceCompatibility = 1.6
anymore attempting to build everything with 1.8 version of Java.
I added the following to the root build.gradle
:
allprojects {
sourceCompatibility = 1.6
eclipse.project {
natures 'org.springsource.ide.eclipse.gradle.core.nature'
}
// more stuff here ...
}
This helped with the root project, but had no effect on any other project. I added the same thing to subprojects with the same unsatisfactory result. I have to say than even after the nature had been added to the root project and Gradle plugin options became available for the root again I still don't see the "G" icon.
So it looks like I have 2 problems with the gradle setup.
Disappearance of the gradle nature. After a few runs Eclipse stops recognizing gradle projects. I wouldn't even face the second problem if that worked properly.
Some problem with my gradle build files or projects layout as my settings don't seem to take effect on subprojects.
Missing "G" icon for the project with restored Gradle nature.
afterEvaluate
resolved races so you could try that to see if you need to delay the change until the end of the configuration phase. – Mirabelle