Basil Bourque
Basil Bourque

Reputation: 339422

Download doc for only one Maven dependency in IntelliJ

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?

Upvotes: 8

Views: 1333

Answers (2)

Codebling
Codebling

Reputation: 11397

<classifier> tag in POM

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

To quote that page:

Another common use case for classifiers is to attach secondary artifacts to the project's main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.

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>

Upvotes: 1

Morfic
Morfic

Reputation: 15518

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

Upvotes: 11

Related Questions