7

In IntelliJ IDEA 2017.2, the Maven Projects panel offers a menu for downloading source code and/or documentation for all the dependencies. Discussed in this other Question. Nice to have, but sometimes overkill. I want the doc for only one dependency.

enter image description here

➠ Is there a way to easily download source and/or documentation for individual libraries rather than all?

And is there a way to browse what dependencies currently have source and/or documentation downloaded?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • Good question - I was wondering about the same thing. Somewhat off-topic: what tool is used to markup the image above? – flow2k Aug 03 '17 at 06:20
  • 1
    @flow2k The translucent orange chalk-marks were made using [*Preview.app*](https://en.wikipedia.org/wiki/Preview_(macOS)) bundled with macOS on any Mac. See [this overview of its editing tools](https://support.apple.com/en-us/HT201740). That same app can also take screens shots, as can the bundled [*Grab.app*](https://en.wikipedia.org/wiki/Grab_(software)). – Basil Bourque Aug 03 '17 at 06:26
  • 1
    @flow2k I also use [*OmniGraffle*](https://www.omnigroup.com/omnigraffle/) to overlay graphics onto screen shots. – Basil Bourque Jun 22 '18 at 06:22

2 Answers2

10

1) Downloading individual documentation and sources:

From the maven tool window, expand the dependencies, and select the desired one, then right click it and chose your option. Although the menu item description which IJ displays in the lower left corner of the IDE reads Downloads xxx for AL DEPENDENCIES for selected projects, it seems to download the details just for the selected libraries. Maybe it's just a reused description or menu?!

download library sources and documentation

P.S. If I'm not mistaking, at one time, it was also possible to download missing docs from the docs popup window (default on win CTRL + Q), but I can no longer see it... I'll come back to this if I manage to find it.


2) Figuring out what libraries have downloaded docs a/o sources:

Go to File -> Project structure (default on Win is CTRL + ALT + SHIFT + S) -> Libraries. Alternatively from the project tool window select a dependency and press F4 (or Right click -> Open library settings).

As you and browse through the list, you'll see that those that already have the documentation a/o sources have a regular coloured font...

having docs and sources

... while those that don't, are coloured in red:

missing documentation


3) Download decompiled class sources:

download sources

Morfic
  • 15,178
  • 3
  • 51
  • 61
  • Opportunity for Intellij to improve: it should be possible to download sources/javadocs form any panel, when one right-clicks on a dependency jar. Currently there are up to 10 (?) variants with different options. And you need a SO question/answer to find out the proper one. :) – Donald Duck Mar 25 '21 at 08:30
1

<classifier> tag in POM

You can also do this in the POM, using the <classifier> element. See Maven reference page.

For Javadoc

Copy your dependency and add <classifier>javadoc</classifier> to it.

For source-code

Similarly, one can add <classifier>sources</classifier> to download the source code. Note the plural form of sources, not source.

Example:

        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-core</artifactId>
            <version>11.8</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-core</artifactId>
            <version>11.8</version>
            <classifier>sources</classifier>  <!-- ⟸ Use `sources` to download source-code for this dependency. -->
        </dependency>
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Codebling
  • 10,764
  • 2
  • 38
  • 66