With maven config, how to get the source?

Tag: maven Author: hesiyi Date: 2011-03-01

With a maven configuration like the following, how do I get the source code for that particular version if it is a third party open source package.

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.2</version>
        <scope>test</scope>
    </dependency>

Best Answer

You could also use maven eclipse plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
        <downloadSources>true</downloadSources>
        <downloadJavadocs>true</downloadJavadocs>
                    ... other stuff ...
    </configuration>
</plugin>

Other Answer1

You can use the maven dependency plugin, with the classifier 'sources'.

http://maven.apache.org/plugins/maven-dependency-plugin/examples/using-dependencies-sources.html

You can narrow this down to a specific group/artifact if you need.