tags:

views:

676

answers:

4

Hello,

Does anyone have any ideea if you can find source jars on maven repositoryes?

+2  A: 

You can, if they are uploaded. Generally they are called "frameworkname-version-source(s)"

Bozho
+2  A: 

you can find info in this related question: Get source jar files attached to Eclipse for Maven-managed dependencies
if you use the eclipse maven plugin then use 'mvn eclipse:eclipse -DdownloadSources=true'

Stefan De Boey
+3  A: 

If a project creates a jar of the project sources and deploys it to a maven repository , then you'll find it :)

Just FYI, sources artifacts are generally created by the maven-source-plugin. This plugin can bundle the main or test sources of a project into a jar archive and, as explained in Configuring Source Plugin:

(...) The generated jar file will be named by the value of the finalName plus "-sources" if it is the main sources. Otherwise, it would be finalName plus "-test-sources" if it is the test sources.

The additional text given to describe an artifact ("-sources" or "-test-sources" here) is called a classifier.

To declare a dependency on an artifact that uses a classifier, simply add the <classifier> element. For example:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate</artifactId>
  <version>3.2.7.ga</version>
  <classifier>sources</classifier>
</dependency>

Note that you generally don't do this, most IDEs provide support to download sources (and/or JavaDoc) from the main artifact without declaring explicitly a dependency on them.

Finally, also note that some repository search engines allow to search for artifacts using the classifier (at least Nexus does with the advanced search). See this search for example.

Pascal Thivent
+5  A: 

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.

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

Alain O'Dea