HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaCritical

Get source JARs from Maven repository

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
sourcemavenfromjarsrepositoryget

Problem

Does anyone have any idea if you can find source JARs on Maven repositories?

Solution

Maven Micro-Tip: Get sources and Javadocs


When you're using Maven in an IDE you often find the need for your IDE to resolve source code and Javadocs for your library dependencies. There's an easy way to accomplish that goal.

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc




The first command will attempt to download source code for each of the dependencies in your pom file.


The second command will attempt to download the Javadocs.


Maven is at the mercy of the library packagers here. So some of them won't have source code packaged and many of them won't have Javadocs.


In case you have a lot of dependencies it might also be a good idea to use
inclusions/exclusions to get specific artifacts, the following command
will for example only download the sources for the dependency with
a specific artifactId:

mvn dependency:sources -DincludeArtifactIds=guava


Source: http://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/

Documentation: https://maven.apache.org/plugins/maven-dependency-plugin/sources-mojo.html

Code Snippets

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
mvn dependency:sources -DincludeArtifactIds=guava

Context

Stack Overflow Q#2059431, score: 847

Revisions (0)

No revisions yet.