3

There is a similar question (How do I attach source code into a project's library in Eclipse?).

However, in my case the jar has the description non modifiable and the option Edit is not possible. What to do in this case?

Here is the picture.
enter image description here

Xcodian Solangi
  • 2,342
  • 5
  • 24
  • 52
Alex
  • 7,007
  • 18
  • 69
  • 114
  • @Oleg, the picture is the same as in the example but the Edit is not enabled. Plus, after (None) I can see not modifiable – Alex Oct 14 '17 at 17:20
  • `attach jar` is just to be able to show sources for classes it is not nor editing. – Thorbjørn Ravn Andersen Oct 14 '17 at 17:30
  • 1
    Yes, apparently it's a thing. Have you seen https://discuss.gradle.org/t/buildship-2-0-imported-dependency-non-modifiable-in-eclipse/21436 ? @ThorbjørnRavnAndersen Sometimes it's locked by plugins and then you can't show them. – Oleg Oct 14 '17 at 17:32
  • If you’re actually asking about the sources for the standard Java classses, you should be using and building against a full JDK. – nitind Oct 15 '17 at 04:00
  • @nitind, I am looking from the source for the jars from the .gradle repository – Alex Oct 17 '17 at 13:49
  • One of the answers from Oleg's link would seem to be how this is handled. – nitind Oct 17 '17 at 17:17
  • @nitind I tried, did not work. – Alex Oct 17 '17 at 17:20
  • This might answer your question, https://stackoverflow.com/a/33653146/1030246 – tazmaniax Oct 25 '20 at 12:54

1 Answers1

0

For homegrown projects the solution is to create a source jar for the library that you use. This can be done by adding to build.gradle

task sourceJar(type: Jar, dependsOn: classes) {
    classifier 'sources'
    from sourceSets.main.allSource
}

And then add to publications:

artifact sourceJar

Publish the jars to the local Maven repository, then the source will be attached in Eclipse while referring this library.

Alex
  • 7,007
  • 18
  • 69
  • 114