How do I get the Gradle Eclipse plugin to work with multiple source-sets that have different dependencies?


(Tomas Lycken) #1

I currently have a project with a couple of different source sets, which all have different dependencies - some are used by several source sets, and some are not.

When building Eclipse project files (through ‘apply plugin ‘eclipse’’ in build.gradle and ‘gradle eclipse’ in the terminal) the dependencies are not all added to the .classpath, so Eclipse’s built-in build engine fails to compile the project.

Adding the union of all the dependencies to “compile” got me much closer (I still have some build errors, but now they’re 33 rather than over 1400…) but this seems like a code smell - now I have to duplicate every new dependency and add it here as well in order to make it work with Eclipse.

Is there a better way around this?


(Carlo Luib-Finetti) #2

Wouldn’t the smell disappear if you could partition you “project” with multiple source-sets into different projects and a root project? Then you could also tailor your dependencies as project specifics.

(Hope I understood your problem)


(Tomas Lycken) #3

@carlo, yes - possibly. But the different source sets are not really independent enough to motivate separate projects, I think, so I’d prefer not to split up the project.

Maybe there’s a way to programatically create the union of the dependencies of all the other source sets?


(Peter Niederwieser) #4

You’'ll want something like this:

eclipseClasspath.plusConfigurations = configurations.findAll { it.name.endsWith(“Runtime”) }


(Tomas Lycken) #5

Peter, that was much nicer than what I had come up with =) Thanks a lot!