Maven:如何使用源和依赖项导出项目

gla*_*666 27 maven-2 maven-dependency-plugin

我有Maven项目,包含repo和stuff中的依赖项.我想用所有依赖项"导出"它的源代码,以便我可以在IDE中成功打开它,而不需要在机器上运行Maven.

将项目打包到war文件中时,它包含所有依赖项.

所以我希望将所有依赖项和我的源集合在一个地方,可以使用IDE(Eclipse或IDEA)打开所有检测到的库吗?

cet*_*nar 32

尝试使用目标副本依赖项的maven-dependency-plugin

<project>
[...]
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
          <goal>copy-dependencies</goal>
        </goals>
        <configuration>
          <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>false</overWriteSnapshots>
          <overWriteIfNewer>true</overWriteIfNewer>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>
</build>
[...]
</project>
Run Code Online (Sandbox Code Playgroud)

PS.
您是否了解maven和IDE集成(对于Eclipse pe)​​?Maven可以为特定的IDE生成项目,并将所有依赖的jar包含为变量(指向本地存储库中的这些jar),因此不需要使用副依赖项来处理子文件夹.


Pas*_*ent 10

实际上,没有任何东西会创建一个包含源依赖项的捆绑包.为此,您需要使用一些插件的组合.

对于依赖项,Maven 2 Dependency Plugin及其copy-dependencies将有助于cetnar指出.

对于源代码,您可能需要Maven Source Plugin及其source:aggregate目标(或者可能是Maven Assembly Plugin和预定义的src描述符,但source:aggregate对于多模块构建很方便).

要将整个事物绑定在一起(也许可以解压缩源代码),我会使用Maven Assembly Plugin.