【发布时间】:2014-03-04 19:11:14
【问题描述】:
我正在使用 Maven2 来构建我的项目。我希望我的构建在编译时自动下载依赖项source jars。依赖项可执行 jar 正在正确下载。我的依赖看起来像这样:
...
<dependencies>
<dependency>
<groupId>id.name</groupId>
<artifactId>artifact-name</artifactId>
<version>1403.00</version>
</dependency>
</dependencies>
...
我确实有 maven 源插件:
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
我也尝试将此配置添加到 maven-source-plugin 下的 pom 中:
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
我需要在我的 pom 文件中添加什么来实现这一点?
【问题讨论】:
-
您不需要源插件,只需执行 mvn dependencies:source 并且您在 pom 中的任何依赖项都将与它们的源一起下载。如果您使用的是 IntelliJ,那么有一个按钮可以为您执行此操作。
-
这不是一个重复的问题。该问题的公认答案使用 CLI。我不想使用 CLI。