Custom Plugins Don't Include Source

(William Lichtenberger) #1

For a custom gradle plugin, you have the following lines:

dependencies {

compile gradleApi()

compile localGroovy()


But when applying the eclipse plugin, and building the classpath. It doesn’t include sources. Is there an easy way to get source jars along with the gradleApi and localGroovy?

The most useful would be the gradle sources, but it would be nice for everything to be included.

(Peter Niederwieser) #2

Unfortunately, there is no easy way. What I’ve done before is to download the Gradle distro and configure ‘eclipseClasspath’ to attach the distro’s ‘src’ directory to each Jar that has ‘gradle’ in its name.

(William Lichtenberger) #3

Not to be lazy… but mind posting the code that does that?

(William Lichtenberger) #4

Not ideal, but this works:

eclipse.classpath.file.withXml { classpath ->

String srcDir = “${gradle.gradleHomeDir}/src”.replace("\", “/”)

classpath.asNode().each { groovy.util.Node node ->

if ( node.@kind == “lib” && node.@path.contains(’/gradle’)) {

node.@sourcepath = srcDir




This assumes you’re running with a gradle distro that has the source included.