我已成功使用mvn -U dependency:copy-dependencies
下载所有依赖项 - 比如说module-a.jar,module-b.jar和module-c.jar。
我不需要将它们放在一个平面目录中,而是需要一个特定层次结构的罐子并压缩。
release.zip
|
- base/classes/
| |
| - module-a.jar
|
- customer/
|
- classes/
| |
| - module-b.jar
|
|
- plugins/
|
- module-c.jar
有4个项目,上面的3个模块加上聚合某个版本中所有模块的项目。
是否可以告诉maven或maven-dependency-plugin将依赖项复制到所需的结构中?怎么样?
答案 0 :(得分:0)
我使用maven程序集插件和自定义程序集描述符。在那个描述符中,我不得不使用一个模块集。在其中,我可以将所有不同的目标目录(及其内容)管理为dependencySet
s。
我必须设置一个新项目,其中包含我想要打包为依赖项的所有jar。在同一个项目中,我必须参考汇编描述符来配置maven程序集插件。
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>install</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<moduleSets>
<moduleSet>
<!-- Needed to have access to all projects in multi module build -->
<useAllReactorProjects>true</useAllReactorProjects>
<!-- If there is no include, every dependency (or at least more) are included -->
<includes>
<include>com.company:artifact_01</include>
</includes>
<binaries>
<unpack>false</unpack>
<outputDirectory>main/dir</outputDirectory>
<dependencySets>
<dependencySet>
<includes>
<include>com.company:artifact_02</include>
<include>com.company:artifact_03</include>
</includes>
<outputDirectory>/main/dir</outputDirectory>
</dependencySet>
<dependencySet>
<includes>
<include>org.apache.felix:org.apache.felix.framework</include>
</includes>
<outputDirectory>/dir/felix</outputDirectory>
</dependencySet>
<dependencySet>
<includes>
<include>com.company:artifact_04</include>
</includes>
<outputDirectory>/dir/felix/plugin</outputDirectory>
</dependencySet>
</binaries>
</moduleSet>
</moduleSets>
</assembly>