Incomplete Eclipse Classpath when using custom sourceSet(?)

Hi there,

I stumbled upon an issue while generating the eclipse ‘.classpath’ file.

Using Gradle 1.6, and given the following minimalistic buildfile:

apply plugin: 'java'
apply plugin: 'eclipse'
  repositories {
  sourceSets {
  dependencies {
    testCompile (group: 'jmock', name: 'jmock-cglib', version: '1.1.0')
    intTestCompile (group: 'commons-io', name: 'commons-io', version: '2.4')
  task echoEclipseSourceSets() << {
    eclipse.classpath.sourceSets.each { println it }

… why doesn’t ‘commons-io’ end up in the eclipse classpath? Since the eclipse plugin picks up all sourceSets when generating eclipse source directories, shouldn’t it also pick up all dependencies of those sourceSets?

… or am I missing something?

Interestingly, ‘eclipse.classpath.sourceSets’ seems to know about the intTest sourceSet: The ‘echoEclipseSourceSets’ yields:

$ gradle echoEclipseSourceSets
source set 'int test'
source set 'main'
source set 'test'

Thanks in advance, Mike

Hi Mike, I think you just need to add something like:

eclipse {
        classpath {
            plusConfigurations += configurations.intTestCompile

Ah, nice, thx for the hint, joel :slight_smile: I wasn’t aware that a sourceSet implicitly creates configurations like this :wink:

Nevertheless, @gradle staff: shouldn’t gradle do that automatically, since it also includes the sourceset’s source folders in eclipse automatically? Putting a sourceset’s source files in an eclipse project, without the corresponding dependencies will always create projects with compile errors by default… which seems like a bad behavior :wink:

Plus you’d need to add the same in to the idea configuration if you’re using IntelliJ as well…