Browsing Javadocs, Archives, and Sources with Nexus Pro 1.5.0


February 2, 2010 By Damian Bradicich

If you’ve ever wondered about the contents a JAR or artifact in a Maven repository, you’ve probably had the experience of having to download and unpack it on your local workstation just to see what it contains.    It shouldn’t be this difficult and tedious to inspect an archive in a remote repository, and with Nexus Professional 1.5.0 we’ve added the capability to browse the contents of an archive.  In addition, we’ve built-in some intelligence that allows you to directly browse Javadoc contained in JAR archives.   In this post, I’m going to give a quick tour of this new feature now available in Nexus Professional 1.5.0.

Browsing Repository Archives

The Archive Browser Plugin will allow you to browse the contents of any JAR, WAR, EAR or ZIP file in the Nexus UI (or over REST if you so desire).  You can now view the contents of source JARs, view html documentation stored in javadoc JARs, or browse the contents of the archives, to validate contents.

To browse the contents of an archive in a Nexus repository, click on Browse Storage and then click on an archive.  When browsing the contents of your repositories, you will find that clicking on a file of the proper type (currently just .jar, .war, .ear or .zip files) will bring up a new panel which shows the contents of an archive.


Clicking on a file in the archive browsing interface will cause Nexus to serve this file to your browser.   If you are reading a file that your browser can display (like an image or a text file), the file will be displayed by your browser; otherwise, you will be prompted to download the file to your workstation.   You can use this functionality to…

…Browse Java Source

You can use this archive browsing functionality to browse source code contained in Source JARs.    The following figure shows you what you would see, if you wanted to load the CopyUtils.java file from commons-io version 1.3.2.   Because commons-io 1.3.2 has an available sources JAR artifact, you can browse the source.

If you are looking for the source of a specific class, you can search for artifacts by class name in the Nexus search interface.   Once you’ve located the artifact that has a specific class with Nexus Search, you can download the artifact from the remote repository, browse storage, and view the source of the class within Nexus.

(Alternatively, if you installed m2eclipse, an Eclipse plugin which can read the Nexus index and interact with Maven repositories, you can simply expand a dependency JAR on the Maven classpath and double-click on a particular class.   If you need to browse source from Eclipse, you should consider installing m2eclipse.  There is no easier way to browse source.)

Viewing Javadocs

I imagine that the most useful portion of this new set of features is the ability to view javadocs.  We have created a shortcut which is available on files named (filename)-javadoc.jar.  Simply right click on the file, and you are given a context menu, with a new option ‘View Javadoc’.  This will open a new browser window that will be directed to the index.html in the root of the jar file.    From this index.html you can click on HTML links and the resulting pages are all served from Nexus.

Although viewing javadocs and sources jars is probably the main point of this plugin, it is generic enough that you can view contents of any jar/war/ear/zip file, for whatever purposes you require.  Make sure your webapp bundle has the proper libraries in it, validate that a jar file contains the class files you think it should, and anything else you can dream up.

Javadoc and Archive Browsing Permissions

There is also a new privilege tied to this functionality, should you only want certain users to be able to use this feature.  You can control access to these archiving browsing options by granting and revoking the “Browse Archive Files (read)” permission shown in the following figure.

That’s all for now from Nexus, just making the little things in development life easier.   To get started, download a free evaluation of Nexus Professional 1.5.0 .