Search code examples
maven-2javadoc

How can I view javadocs that have been added to a maven repository?


I know I can use maven to pull the javadocs for an artifact (if they've been added), which should come through as a JAR (right?), which I can then unpack and browse. My problem is, I'm trying to figure out which of a series of artifacts have the particular package I'm hunting for. I could download a half-dozen javadoc packages, unpack all of them, then open the index files one at a time, but that sounds like it would be pretty unpleasant.

There must be a better way! I noticed that Nexus supports javadoc artifact browsing, but apparently only in the Pro version (which we do not have, and are unlikely to get any time soon). I'd prefer a GUI solution, though I'd settle for a command line answer, provided it's something along the lines of showmethedocs groupId:artifactId [version].

ETA: To clarify: I'm looking specifically to compare multiple versions of an artifact, or multiple different but similar artifacts ("foo:core" versus "foo:utils" versus "foo:extra" or something) when I'm not sure what artifact actually contains the package / class I need. Maybe there's a better way to do that, and I asked the wrong question? If I add each artifact as a Maven dependency and check the docs in Eclipse, that can work, but if there's 20 old versions of an artifact, and exactly one of them has the method I'm looking for, it could take a while.


Solution

  • If you run

    mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true

    from the root of your project, it will download any sources & javadocs on the remote repository to your local repository. If you have m2eclipse, you can set that in the preferences to happen automatically in the background, and then drill down to the dependency you want, right click and then say 'open Javadoc'. See:

    http://www.sonatype.com/people/2008/10/browsing-javadoc-for-dependencies-in-eclipse-m2eclipse/