问题

有没有办法可以配置maven toalwaysdownload源和javadocs?指定-DdownloadSources=true -DdownloadJavadocs=trueeverytime(通常伴随着运行mvn编译两次因为我第一次忘记)变得相当乏味。


#1 热门回答(228 赞)

打开settings.xml文件~/.m2/settings.xml(如果它不存在,则创建它)。添加添加了属性的部分。然后确保activeProfiles包含新的配置文件。

<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>

#2 热门回答(144 赞)

在我的情况下,"settings.xml"解决方案不起作用,所以我使用此命令来下载所有源:

mvn dependency:sources

你也可以将它与其他maven命令一起使用,例如:

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

要下载所有文档,请使用以下命令:

mvn dependency:resolve -Dclassifier=javadoc

#3 热门回答(34 赞)

来自Google的人的回答

InEclipse你可以自动下载javadoc来源

为此,右键单击项目并使用

  • Maven - >下载JavaDoc
  • Maven - >下载源代码

原文链接