Maven – Always download sources and javadocs

2019-01-02 21:26发布

Is there a way I can configure maven to always download sources and javadocs? Specifying -DdownloadSources=true -DdownloadJavadocs=true everytime (which usually goes along with running mvn compile twice because I forgot the first time) becomes rather tedious.

标签: java maven
9条回答
做个烂人
2楼-- · 2019-01-02 22:02

On NetBeans : open your project explorer->Dependencies->[file.jar] rightclick->Download Javadoc

查看更多
Luminary・发光体
3楼-- · 2019-01-02 22:07

Open your settings.xml file ~/.m2/settings.xml (create it if it doesn't exist). Add a section with the properties added. Then make sure the activeProfiles includes the new profile.

<settings>

   <!-- ... other settings here ... -->

    <profiles>
        <profile>
            <id>downloadSources</id>
            <properties>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </properties>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>downloadSources</activeProfile>
    </activeProfiles>
</settings>
查看更多
Summer. ? 凉城
4楼-- · 2019-01-02 22:11

In my case the "settings.xml" solution didn't work so I use this command in order to download all the sources:

mvn dependency:sources

You also can use it with other maven commands, for example:

mvn clean install dependency:sources -Dmaven.test.skip=true

To download all documentation, use the following command:

mvn dependency:resolve -Dclassifier=javadoc
查看更多
贼婆χ
5楼-- · 2019-01-02 22:12

I think it can be done per plugin. See this chapter from the Maven book.

You might be able to configure the dependency plugin to download sources (even though I haven't tried it myself :-).

查看更多
时光不老,我们不散
6楼-- · 2019-01-02 22:18

Just consolidating and prepared the single command to address source and docs download...

mvn dependency:sources dependency:resolve -Dclassifier=javadoc
查看更多
Rolldiameter
7楼-- · 2019-01-02 22:20

Answer for people from Google

In Eclipse you can automatically download javadoc and sources.

To do that, right click on the project and use

  • Maven -> Download JavaDoc
  • Maven -> Download Sources
查看更多
登录 后发表回答