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

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?

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)

@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?

You’'ll want something like this:

eclipseClasspath.plusConfigurations = configurations.findAll {“Runtime”) }

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