Attach Sources to your Maven Artifacts!
Improving the central maven repository
One of the key advantages of open source software besides being available free of charge is - well - that its source is available to developers reusing existing open source libraries.
Having the source available in your IDE when developing against an API is such a great thing that I wonder why so few open source projects care to make this asset easily available to their “customers”.
Maven and its central repository (aka ibiblio) provides a great facility to publish sources along with the jars. All it takes is a small snippet added to your project's POM (or its parent POM) before you upload the bundle to the repo:
<build>
<plugins>
...
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
I really wonder why this isn't the default in Maven and encourage all open source developers to provide sources for their releases.
Consuming the sources is handled by the IDE plugins Maven provides but again this is not the default:
mvn -DdownloadSources=true idea:ideaor
mvn -DdownloadSources=true eclipse:eclipse
Et voilà: all sources attached to the jars and available through Shift-Click or whatever your IDE's shortcut is.
Re: Attach Sources to your Maven Artifacts!
mvn source:jar deploy
Similarly >
mvn javadoc:jar deploy
Will upload the javadocs as well. And of course if you specify both "source:jar" and "javadoc:jar" before "deploy", then both will be uploaded.