Eclipse plugin doesn't attach source for the gradleApi() dependency


(Mike Meessen) #1

Hi,

The eclipse plugin usually downloads all source code and attaches to the artifacts within eclipse by default. This seems to work whenever source code is available, which is great.

However, I’m developing Gradle Tasks / Plugins and am using the special “gradleApi()” dependency which doesn’t seem to attach the gradle sources within eclipse, which doesn’t make sense since the gradle-all distribution includes the gradle sources.

Having the gradle sources attached within eclipse would make task / plugin development a lot easier.

Best regards, Mike


(Rolf Suurd) #2

As a workaround, you can attach the sources from the gradle distribution if you have downloaded them:

import org.gradle.plugins.ide.eclipse.model.*
  eclipse {
 classpath {
  file {
   whenMerged {Classpath cp ->
    String gradleHome = gradle.getGradleHomeDir().absolutePath.replace(File.separator, '/')
    String gradleSrc = "${gradleHome}/src"
      cp.entries.each {ClasspathEntry entry ->
     if ((entry in AbstractLibrary) && (entry.library.file.name.startsWith('gradle-'))) {
      entry.sourcePath = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory().fromPath(gradleSrc)
     }
    }
   }
  }
 }
}

Cheers,

Rolf


(Mike Meessen) #3

Thanks for your workaround, Rolf. That worked for me. Of course, it would be desirable for Gradle to do that automatically before 1.0 is released :wink:

Best regards, Mike


(Peter Niederwieser) #4

I’ve created GRADLE-2133 for this.