Monday, 9 February 2009

Attaching javadocs and sources to Maven install/deploy

When installing maven artifacts to your local repository, or deploying them to a remote repository, it is really helpful to attach a copy of the source code and the javadoc.

If you code Java in eclipse, you can use the m2eclipse plugin to automatically download the source and javadoc files for dependencies, and then display the associated javadoc by hovering over a method or when using dot-complete, and inspect the source code by pressing F3.

So, how do you attach the source and javadoc to an installation or deployment?
mvn clean javadoc:jar source:jar install
This will install three jar files to your local repository:
  • (artifactId)-(version).jar - containing the compiled artifact
  • (artifactId)-(version)-javadoc.jar - containing the artifact's javadoc
  • (artifactId)-(version)-sources.jar - containing the artifact's source files

2 comments:

mcbeelen said...

or do: mvn clean install -DperformRelease=true

Paolo G. Giarrusso said...

For me, using -DperformRelease=true put all the sources in the source archive, while with just source:jar install the source archive contained only resources and no actual source, for some reason - I hadn't used clean though, in either case.

Post a Comment