基本上我有一个具有这种结构和依赖关系的多模块项目
pom - With dependencies with scope provided
+ ---- mod1 - with mod1 dependencies
+ ----- depends on libAAA
+ ------ depends on libBBB
+ ---- mod2 - with mod2 dependencies
+ ----- depends on libXXX
+ ------ depends on libYYY
汇编(使用maven-assembly-plugin)预计如下所示:
bin/lib - Contains all provided dependencies
bin/mod1/ - Contains mod1 artifact
bin/mod1/lib - Contains mod1 dependencies (only mod1)
bin/mod2/ - Contains mod2 artifact
bin/mod2/lib - Contains mod2 dependencies (only mod2)
一切都像预期的那样“差不多”,但是所有PROJECT依赖 被复制到mod1 / lib和mod2 / lib,所以生成的程序集看起来像这样
bin/mod1/lib
bin/mod2/lib
BOTH containing libAAA, libBBB, libXXX, libYYY
我期望获得的是:
bin/mod1/lib
containing libAAA, libBBB
bin/mod2/lib
containing libXXX, libYYY
有人知道是否可以在不使用过滤器的情况下复制“隔离”(不确定使用哪个词)模块依赖于这些目录?
提前谢谢, 托尼奥答案 0 :(得分:0)
我正在添加程序集描述符。
如描述的那样,该描述符设置在称为分布的“pom”模块中 在用于多模块项目的maven-assembly-plugin文档中。
我尝试生成2个moduleSet而不只是一个, 每个模块一个,结果与上述相同。
这是XML& pom配置:
<?xml version="1.0" encoding="UTF-8"?>
<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>bin</id>
<formats>
<format>dir</format>
<format>jar</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>basic-modules</baseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>provided</scope>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>*:payment-api</exclude>
</excludes>
</dependencySet>
</dependencySets>
<moduleSets>
<moduleSet>
<!-- Enable access to all projects in the current multimodule build! -->
<useAllReactorProjects>true</useAllReactorProjects>
<!-- Now, select which projects to include in this module-set. -->
<includes>
<include>*:paypal-payment</include>
<include>*:moneris-payment</include>
</includes>
<binaries>
<outputDirectory>${module.artifactId}</outputDirectory>
<outputFileNameMapping>${module.artifactId}.${module.extension}</outputFileNameMapping>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>${module.artifactId}/lib</outputDirectory>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>basic-modules-${pom.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptor>assembly.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>