2

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.
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147

1 Answers1

2

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

Community
  • 1
  • 1
Will Humphreys
  • 2,677
  • 3
  • 25
  • 26
  • Thanks for your answer. I'm trying it out but running into some problems. Is it possible to specify a local url because I tried entering the remote url at which the jar exists but IntelliJ is failing to find documentation in there. Probably because it's an Artifactory url that requires username and password? I tried entering a local path that points to the javadoc jar file with the `jar://` protocol (ending with `!/`) and I tried entering the local path of the jar with the `file://` protocol. No luck. In both cases IntelliJ doesn't even add the Javadoc url like in ur screenshot. Please advise. – Adil Hussain Dec 12 '16 at 11:41
  • To use the Junit javadoc jar I needed to download the jar and then unzip into a empty directory. My path ended up looking like file:///tmp/junit – Will Humphreys Dec 12 '16 at 11:51
  • 1
    Awesome. That worked. Thanks so much. Would be great if IntelliJ could automatically link to the dependency's Javadoc like it does with the Sources. But I'll make a separate question/request for that. This does the job for now. Thanks again. – Adil Hussain Dec 12 '16 at 12:06
  • Created an IntelliJ feature request [here](https://youtrack.jetbrains.com/issue/IDEA-165338). Anyone reading this... Please upvote if you would like to see that feature added to IntelliJ. – Adil Hussain Dec 12 '16 at 12:49