Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 996
Basil Bourque Avatar asked Aug 03 '17 04:08

Basil Bourque


People also ask

How do I download JavaDoc from IntelliJ?

Click on the "maven projects" (make sure tool buttons are on) on the right side of intelij and then click on "Download Documentation".

How do I download Maven dependencies?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.

How do I exclude a specific version of a dependency in Maven?

Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.


Video Answer


2 Answers

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

like image 83
Morfic Avatar answered Oct 21 '22 07:10

Morfic


<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>
like image 20
Codebling Avatar answered Oct 21 '22 05:10

Codebling