是否有一种方法可以将maven配置为始终下载源代码和javadocs?每次指定-DdownloadSources=true -DdownloadJavadocs=true(这通常伴随着运行mvn compile两次,因为我忘记了第一次)变得相当乏味。


当前回答

不确定,但是你应该能够通过在settings.xml中设置一个默认的活动配置文件来做一些事情

See

参见http://maven.apache.org/guides/introduction/introduction-to-profiles.html

其他回答

我使用Maven 3.3.3,无法获得默认配置文件在用户或全局设置.xml文件中工作。

作为一种变通方法,您还可以在pom.xml文件中添加一个额外的构建插件。

<properties>
    <maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
</properties>
<build>
    <plugins>
        <!-- Download Java source JARs. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>${maven-dependency-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

对于intellij用户,在pom.xml文件中,右键单击任意位置并选择Maven ->下载源代码和文档。

对于依赖级的源代码(pom.xml),您可以添加:

<classifier>sources</classifier>

为了跟踪kevinarpe的答案,这对sources和Javadocs都做了:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>sources</goal>
                            <goal>resolve</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <classifier>javadoc</classifier>
                </configuration>
            </plugin>
        </plugins>
    </build>

在NetBeans上: 打开你的项目资源管理器->依赖项->[file.jar]右键单击->下载Javadoc