Reputation: 14388
I have a gradle build script that defines a file dependency.
dependencies {
testCompile files('lib/test/wibble-1.0.jar')
}
I have a source jar for the library that I would like to add to the dependency so that with in eclipse I can navigate to the source. How do I add that information to the dependency?
Upvotes: 0
Views: 239
Reputation: 123960
Adding source Jars for artifacts not resolved from a Maven repository requires some scripting of eclipse.classpath
(see EclipseClasspath
in the Gradle Build Language Reference). It could look like this:
import org.gradle.plugins.ide.eclipse.model.*
eclipse {
classpath {
file {
whenMerged { Classpath classpath ->
classpath.entries.each { ClasspathEntry entry ->
if (entry instanceof AbstractLibrary && entry.library.file == file("lib/test/wibble-1.0.jar")) {
entry.sourcePath = fileReferenceFactory.fromFile(file("lib/test/wibble-1.0-sources.jar"))
}
}
}
}
}
}
You could generalize this code to add all source Jars in the lib
directory that adhere to some naming convention.
Upvotes: 1