2

I have a gradle project and I want to add a .jar and attach its source to the "Project and External Dependencies" folder when it builds. Adding the .jar bit is fine, I can do that. Added the line

compile files('lib/choco-solver-4.10.0.jar')

under the dependencies{} section and it does it just fine. No problems.

I have choco-solver-4.10.0-sources.jar as well, which is the source code for the choco-solver-4.10.0.jar. I want this source code so that i can dig into the code of it when debugging/coding.

I don't know how and can't find a way (after 45 minutes of googling searching) to attach the source code to this so that it ends up with the .jar in "Project and External Dependencies" attached to choco-solver-4.10.0.jar. If someone could point me to a previously answered question or google result that shows me to do this i'd be equally as grateful as if someone gave me an answer here.

I can add choco-solver-4.10.0.jar to the build path of the Eclipse project, but that doesn't seem to help in getting it to sort itself out with Gradle.

I'm genuinely at a loss at the moment. Thanks in advance for any help. Bear in mind that I am a Mathematics graduate who has been coding in java less than a year, and this sort of stuff is very new to me.

1 Answers1

0

Have you tried to add it to your project's properties?

Go to Properties -> Java Build Path -> Libraries

Then select the library you want to attach the source for in the list, expand it, you should see something like that:

Source Attachment: (none)
Javadoc location: (none)
Native library location: (none)
Is not modular - non modifiable
Access rules: (No restrictions)

Click on Source attachment: (none) and then Edit..., from this window you should be able to select your source jar and attach it.

I do not know where you got this library, but there is a plugin in the Eclipse marketplace, named Java Source Attacher, which automatically search for the sources of your library in the popular Java repositories on Internet and attach it to your project.

Archaos
  • 46
  • 4
  • 2
    Already tried Java Source Attacher to no avail. The Source Attachment doesn't work because the .jar ends up in Project and External Dependencies due to gradle, which is fine, except it doesn't allow the editting of the source attachment. – James Robinson Jun 21 '19 at 14:22