Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Maven: how to attach sources to tools.jar

I have to use libraries in tools.jar and have therefor added this dependency:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.6.0</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

Now I would like to attach the sources in Eclipse, so I see what I develop against. I guess nothing will be available in the standard maven repositories (I can't even find anything in download.java.net/com/sun).

I know there is a source archive available, but it contains everything and I would at least need to know what parts of it need to go in the source jar.

Has someone done this? Is there a tools-sources.jar available somewhere? Or can you tell me what parts of the jdk sources I need?

like image 245
Sean Patrick Floyd Avatar asked Sep 07 '10 07:09

Sean Patrick Floyd


People also ask

What are sources jar?

That sources jar is a jar that contains only the source code (the . java files) corresponding to the compiled artifact. It is useful to add it as a source attachment in your IDE, to publish the sources, etc. As it only contains sources, not compiled classes (. class files), it is of no use as a library dependency.


1 Answers

Here's what I did. I downloaded the source archive from openjdk, extracted it and manually linked the jar source to

External Folder -> [unpacked archive basedir]/langtools/src/share/classes

This is not a maven solution, it's eclipse only, but it works.

like image 108
Sean Patrick Floyd Avatar answered Sep 20 '22 15:09

Sean Patrick Floyd