如何使用来自命令行的源安装 Maven 工件?

如何使用源安装 Maven 工件?

所以稍后我不需要在 eclipse 中打开一个项目来查看一些代码。

编辑: 我知道我可以将这段代码添加到 pom.xml 中

<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

但是我想通过命令行来实现(使它更加通用)。

66527 次浏览

To download sources for your dependencies:

mvn eclipse:eclipse -DdownloadSources=true

To attach sources to an installation:

mvn source:jar install

It's also preferable to use the goal source:jar-no-fork in your pom as described on the maven-source-plugin page.

It is quite easy with eclipse, right click the project in project explorer view, click maven menu item , then click download sources..

Simple, get your sources and JavaDocs:

mvn dependency:resolve -Dclassifier=javadoc
mvn dependency:resolve -Dclassifier=sources

Please use mvn source:jar install to install the Maven artifacts.