How to use sources / javadoc of local compile dependency in Eclipse / Buildship

I have a library which is not in any Maven repository, so I include it via

dependencies {
    compile files("$PATH/lib.jar")

Source and javadoc files are available. I would like to include them into Eclipse / Buildship and access them in the same way as it is possible for libraries downloaded from a repository.

I am using Eclipse Neon 4.6.0, Buildship 1.0.16 and Gradle 2.14.

I’d say the easiest option would be to store your files in a maven-like folder hierarchy

$PATH/xxx/yyy/lib/1.0/lib-1.0.pom (not required but maven can generate this for you)

Then include it via

repositories {
   maven {
      url uri("$PATH")
dependencies {
   compile 'xxx.yyy:lib:1.0'

If you want to script this process you might want to invoke the maven command line

1 Like

Thank you very much, that saved my day!

For everybody who does not use maven (like I did not): Apparently, a dot (".) in “xxx” translates into a subfolder ("/") in the path (adjust folder structure accordingly).

Example updated to include this

This will improve with Gradle 3.0 and the next Buildship release. You’ll be able to freely configure the source attachment of any classpath entry and Buildship will pick that information up. Stay tuned :slight_smile:

I’m tuned! Any news on how to do this? We have source jars in a flat dir like:

Anyway to get Buildship 2.0 (or earlier) to pick up these sources?

This is possible since Buildship 1.0.18, have a look at the examples in the release notes: Buildship 1.0.18 is now available

OK, thanks! This looks like what I need.
As a developer trying to migrate a old build with checked in eclipse files, it’s very hard to understand what buildship currently can do as there seems to be a bit lacking in the documentation.
The stuff in this release note should really be incorporated into the user guide for Buildship at or another guide with more advanced usage.

Anyhow with this stuff being possible, I’m starting to think this Buildship thing is something we can use :wink:

Yes, we plan to roll these examples into the documentation. Thanks for the feedback :slight_smile: