Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could use the <a href="http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html" rel="noreferrer">maven-eclipse-plugin</a> plugin to download the sources, and give you a list of the source jars that are available (some of your dependencies might not have sources available).</p> <p>The dependency plugin can also download sources, but it's harder to get the list of jars you need.</p> <p>You could try something like this:</p> <pre><code>dir=target/sources mkdir -p $dir mvn eclipse:eclipse -DdownloadSources sed -rn '/sourcepath/{s/.*sourcepath="M2_REPO.([^"]*).*/\1/;p}' .classpath | \ (cd $dir &amp;&amp; xargs -i jar xf ~/.m2/repository/{}) </code></pre> <p>This runs <code>mvn eclipse:eclipse -DdownloadSources</code>, which will download the sources, and write a <code>.classpath</code> file to the local directory. This file contains the paths to your source jars. It looks a bit like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;classpath&gt; &lt;classpathentry kind="src" path="src/main/java" including="**/*.java"/&gt; &lt;classpathentry kind="output" path="target/classes"/&gt; &lt;classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/&gt; &lt;classpathentry kind="var" path="M2_REPO/net/sourceforge/findbugs/jsr305/1.3.7/jsr305-1.3.7.jar"/&gt; &lt;classpathentry kind="var" path="M2_REPO/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar" sourcepath="M2_REPO/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0-sources.jar"/&gt; &lt;/classpath&gt; </code></pre> <p>In my example, you can see that there are sources for the JCIP annotations jar, but not the FindBugs JSR305 jar.</p> <p>The sed command extracts the paths of the source jars (relative to your maven local repository). The xargs command then unpacks each source jar into <code>$dir</code>.</p> <p>The eclipse plugin creates the files <code>.classpath</code> and <code>.project</code> and a directory <code>.settings</code> - you can delete these if you never use Eclipse.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload