For reasons far beyond my control, I’m currently working with a convention for libraries that states that source jar names should follow the following convention: For ‘library.jar’, the source jar should be in the same directory, in ‘library.src.jar’.
Trying to get the ‘.classpath’ files generated by ‘gradle eclipse’ to point to these source jars has been a bit of a trial - they are picked up by gradle as being ivy dependencies, but are then just included as libs.
The best option I’ve been able to find is:
apply plugin: 'eclipse'
eclipse {
classpath {
file {
whenMerged { classpath ->
fileFactory = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory()
classpath.entries.removeAll { it.path.contains('.src') }
classpath.entries.findAll { it.kind=='lib' }.each { it.sourcePath = fileFactory.fromPath(it.path.replace(".jar", ".src.jar")) }
}
}
}
}
Should this be achievable by declaring a ‘compile’ or ‘testCompile’ dependency properly?