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

buildship
eclipse

#1

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.


(Lance Java) #2

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.jar
$PATH/xxx/yyy/lib/1.0/lib-1.0-javadoc.jar
$PATH/xxx/yyy/lib/1.0/lib-1.0-sources.jar
$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


Configuration.allDependencies should include dependencies from compile files
#3

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).


(Lance Java) #4

Example updated to include this


(Stefan Oehme) #5

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:


(Staffan Forsell) #6

I’m tuned! Any news on how to do this? We have source jars in a flat dir like:
libA.jar
libA-src.jar
libA-javadoc.jar

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


(Stefan Oehme) #7

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


(Staffan Forsell) #8

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 https://github.com/eclipse/buildship/blob/master/docs/user/Overview.md 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:


(Stefan Oehme) #9

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