I recently started working with Maven for many of my personal projects. I love the ability to declare my dependencies on various open source projects and to have the dependencies automatically resolved and downloaded. I no longer have to search the web for the software, download the distribution, unzip it somewhere on my disk, and then configure my paths. It is all done automatically.
I use IntelliJ as my Java IDE. IntelliJ has a pretty nice Maven integration. You can import a maven project and all the dependencies and path are automatically configured for you. I found, however, that by default there are a couple pieces missing to get the really slick development environment I desire.
Maven has the ability to download sources and javadoc for the open source libraries you declare. This is wonderful when you are developing and debugging code. Unfortunately the IntelliJ integration doesn’t give you the access you want to those pieces by default. With some research I found that Intellij is able to do all that I want but takes a little extra setup. What follows is a discussion of what I did to complete the picture.
1. Configure IntelliJ to download sources and Javadoc
You must configure IntelliJ to download the sources and javadoc. By default they are not downloaded. You can do this by visiting the Maven/Downloading section of the project settings.
2. Install Firefox
The javadoc downloaded by Maven is in jar format. IntelliJ automatically configures itself to almost use the jar-based javadoc but not quite. To view the configured javadoc IntelliJ fires up a browser window and sends the URL to the browser for display. The problem is that Windows Internet Explorer can not display jar-based javadoc. I researched some and found that the Firefox browser can display jar-based javadoc. You need to install Firefox on your system. In my case I chose to install it as an alternate browser (leaving Windows Explorer as my primary browser).
3. Configure Intellij to use Firefox by default
You need to configure IntelliJ to use Firefox as it’s default web browser so that requests to view javadoc will be sent to there. You can do this by visiting the Web Browsers section of the IDE settings.
4. Install the JarDoc plugin
One problem with the jar-based javadoc integration in IntelliJ is that is generates a jar URL that can not be consumed by any browser that I am aware of. Even though Firefox can display jar-based javadoc it can not do so with the URL that IntelliJ generates. Someone has written an IntelliJ plugin to work around this problem. You need to install the JarDoc plugin. You can do this by visiting the Plugins section of the IDE settings. You will find the JarDoc plugin in the “Available” tab of the plugin configuration.
5. Update your keymap to access JarDoc using the standard javadoc key sequence
Even though JarDoc works around the IntelliJ jar URL problem, it does so using a special key sequence. The normal key sequence for accessing javadoc in Intellij is “Shift-F1”. The JarDoc functionality is installed by default to only active on a special sequence of “Shift-Alt-F1”. I found this rather annoying. I decided to reconfigure my keymap so that JarDoc functionality was invoked using the standard “Shift-F1”. You can do this by visiting the Keymaps section of the IDE settings. You need to create a custom keymap if you haven’t already done so because you can’t modify the built-in keymap. Remove the old mapping for “Shift-F1” then map the JarDoc plugin to “Shift-F1”.