Generate Eclipse projects without specific library dependencies, enabling the Gradle Plugin to manage the dependencies

When I use the Gradle Eclipse Plugin to import gradle projects into Eclipse, it generates classpaths for projects without the individual dependencies. Instead it adds a container dependency to “org.springsource.ide.eclipse.gradle.classpathcontainer”.

How can I generate Eclipse projects with gradle and the eclipse plugin in gradle, that does this, i.e., enables the Gradle plugin in Eclipse to manage dependencies, without generating classpath entries for the individual dependencies? Is there a better way than manually removing those dependencies in the whenMerged hook for example?

Are you saying that you end up with duplicated dependencies, inside and outside the class path container? I’ve never heard of this problem before.

Well, yes. At least right after generating the eclipse classpaths from gradle. But maybe I’m not using the plugin correctly. I haven’t found a way to generate eclipse classpaths where gradle dependencies were enabled by default (is there one?). Instead I’m adding the container manually, like this:

eclipse {
    project {
'org.springsource.ide.eclipse.gradle.core.nature', 'org.eclipse.jdt.groovy.core.groovyNature'
      classpath {
    containers 'org.springsource.ide.eclipse.gradle.classpathcontainer', 'org.springsource.ide.eclipse.gradle.dsld.classpathcontainer', 'GROOVY_DSL_SUPPORT', 'GROOVY_SUPPORT'

This gives me enabled gradle dependencies in eclipse. I’ve managed to remove the extra dependencies using “minusConfigurations”, but that complicates it a bit, since I need to know the configurations.

Is there a better way?

When you work with the Eclipse Gradle integration, you don’t generate the class paths yourself. You also don’t have to add the natures and containers.

You mean that I should use the gradle import wizard instead? I wanted to simplify by generating all necessary config by just running the gradle eclipse task and importing the eclipse projects as usual, but maybe it is better to use the import wizard.

Yes. Either use ‘gradle eclipse’, or use the STS tooling.

One reason to generate the eclipse projects was that I want to activate other plugins, findbugs and checkstyle for instance, and generate settings for those. Is that still possible to do automatically while importing with STS tooling?


How can I do that? I’d prefer that the user didn’t have to activate those plugins manually.

As before - configure the Eclipse plugin. Just don’t manually trigger generation of project files.

Ok, two followup questions:

  1. The “Import Gradle Project” dialog has an import option “Run before” with “cleanEclipse eclipse” parameters, enabled by default. Is this the correct way to import? Won’t that give the same result as running “gradle eclipse” from command line?

  2. In the projects I import the checkstyle plugin doesn’t seem to be activated. Should it be?

  1. Please refer to the documentation of STS plugin. If it does not answer the question, it’s best if you ask in the STS forums 2. Gradle IDE (eclipse/idea) tasks do not generate the settings for code quality Eclipse plugings. As far as I know, STS does not do it, either. In theory you can hook into IDE metadata generation via whenMerged / withXml API or if necessary create own tasks that generate the checkstyle Eclipse plugin metadata.

Hope that helps!

That helps! Thank you both for your answers.