I have the following project structure:
build.gradle
)
build.gradle
)build.gradle
)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.
Using the Buildship: Eclipse Plug-ins for Gradle I had to use natures string org.eclipse.buildship.core.gradleprojectnature
For Example:
allprojects {
eclipse.project {
natures 'org.eclipse.buildship.core.gradleprojectnature'
}
}
Install Gradle plug-in for Eclipse
Then use Eclipse menu: File -> Import... to import the Gradle project. It will add the Gradle Nature. And 2 extra Eclipse views, one for quickly running Gradle tasks. One for Gradle output of those executed tasks.
TIP: Before importing an existing Gradle project, create a New Gradle project, to see if the Gradle plug-in is working as expected.
New Gradle Project
This should set up a minimal Gradle project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With