[FIXED] How to link a Gradle project to the Javadoc of its dependencies?

Issue

I have a Gradle project consisting of an Android application module. I cannot figure out how to get the Android application module to link into the Javadoc of its dependencies.

I have specified the following in the project’s root-level build.gradle file as well the Android application module’s build.gradle file:

apply plugin: 'idea'

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

I can see by inspecting the ~/.gradle/caches/modules-2/files-2.1 folder on my machine that the Javadoc for the dependencies has indeed been downloaded.

However, when I inspect the xml files in the .idea/libraries folder in my project, I see that the JAVADOC tag is always empty. The CLASSES and SOURCES tags are non-empty and, of course, link correctly to the classes and sources respectively. How can I get IntelliJ to link to the Javadoc also (so that when I press F1 on one of the dependency’s classes or methods I see the Javadoc)?

Afterwords

  1. I have tried hitting the "Refresh all Gradle projects" button as well as hitting "Invalidate caches / Restart…". That makes no difference.
  2. I have tried this on both IntelliJ IDEA Ultimate 2016.3 as well as Android Studio 2.2.3. Same problem on both.
  3. I am aware that I can see Javadoc for dependencies of my application which have published Sources. The problem is that some of my application’s dependencies have published Javadoc but not Sources.

Solution

You can manually specify the JavaDoc location in Project Structure | Libraries | Specify Documentation URL. This will populate JAVADOC element in the .idea/libraries directory. You can point it at a url or download a Javadoc jar.

To get the downloaded jar to work I needed to unzip the jar and point the IntelliJ url to the directory containing the unzipped javadocs. The resulting url would look like file:///tmp/junit with unzipped javadocs being inside the junit directory.

Show where to click in the project strucuture

There is a good answer here Attaching additional javadoc in Intellij IDEA

Answered By – Will Humphreys

Answer Checked By – David Marino (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published