2

I use gradle with eclipse and have a local jar and its source jar:

I include the local jar as:

dependencies {
  compile name: 'mgwt-2.0.1-SNAPSHOT'
}

I have also the local source jar of this local jar: mgwt-2.0.1-SNAPSHOT:sources.

How can I include this such that eclipse can read the code?

Michael
  • 32,527
  • 49
  • 210
  • 370
  • eclipse > your project > build path > libraries > your jar > expand > source attachement > edit ... or [here](http://stackoverflow.com/questions/122160/is-there-an-easy-way-to-attach-source-in-eclipse) – guleryuz Jan 03 '16 at 07:35

1 Answers1

0

We got this to work by defining a local repository for those jars:

allprojects {
    repositories {
        flatDir name: 'localRepo', dirs: [new File("theDirectory").absolutePath]
    }
}

The directory theDirectory contains jar files complying to Maven naming conventions:

mgwt-2.0.1-SNAPSHOT.jar
mgwt-2.0.1-SNAPSHOT-sources.jar

We refer to these jar files by omitting the groupId as follows:

dependencies {
    compile ':mwgt:2.0.1-SNAPSHOT'
}

Eclipse (and IntelliJ, too) then recognizes the corresponding sources-Jar and connects them correctly.

  • does not work for me. Doesn't give any meaningful error message except "could not resolve". Would be nice if you added more details so people understand what this is doing excactly. maybe "theDirectory" could be more specific? – JPT Nov 16 '22 at 17:07