Is there a way to specify the source jar location for a file dependency?

(Gui Forget) #1


I have a multi-java-project setup in Eclipse with a few libraries which do not exist in any repository that I know of. So I have a global ‘lib’ directory where I store the binary and source archives. A few projects then declare some file dependencies when necessary.

Is there a way to configure the eclipse plugin so that when generating the .classpath file, it includes the location of the source jar and/or the javadoc for the file dependencies? I checked the SelfResolvingDependency interface definition and I didn’t see anything that could help me do that so I’m guessing that’s not possible.

Thank you.

(Radim Kubacki) #2

Simpler than defining your special repository format where you will associate JARs with their sources is to use ‘withXml’ hook in Eclipse plugin and modify generated ‘.classpath’ file. Some references: and and you will put your code into block like this: ‘’’ eclipse {

classpath {

file {

withXml {

def node = it.asNode()


} } ‘’’

(Peter Niederwieser) #3

If I’m not mistaken, Gradle 1.12 will do this automatically for file dependencies whose sources Jars have a ‘sources’ classifier, and whose Javadoc Jars have a ‘javadoc’ classifier.

(Scott Palmer) #4

Is there a way to do this if the javadocs/sources are not in a jar but in expanded form on the local filesystem?

(Peter Niederwieser) #5

It should be possible with post-processing of the ‘.classpath’ file.

(Scott Palmer) #6

Well, as a hack to work around it, sure. But this needs to be something that the tooling API can handle. I want to use NetBeans anyway :slight_smile:

(Radim Kubacki) #7

AFAICT if you modify idea model with a similar hook that Peter was suggesting (see withXml in NetBeans will likely pick it up.