且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多模块Maven项目中的聚合依赖项

更新时间:2022-06-12 22:20:34

您将必须配置依赖项插件才能将依赖项复制到特定位置.这可以通过outputDirectory配置属性来完成.

You will have to configure the dependency plugin to copy depdendencies to a particular location. This can be done by the outputDirectory configuration property.

<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>${outputDir}</outputDirectory>
         </configuration>
      </execution>
   </executions>
</plugin>

但是,如果您尝试执行此操作以进行分发,则建议您使用 Maven程序插件

But if you trying to do this for distribution, I'd recommend you create an assembly using the maven assembly plugin

文档说:

Maven 2.0的Assembly Plugin主要用于允许用户聚合 项目输出及其依赖项,模块,站点文档和其他文件 到一个可分发的存档中.

The Assembly Plugin for Maven 2.0 is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive.