问题描述
我需要从主目录中的多模块项目中组装jar.让我们有一个这样的结构:
Hi I need to assembly jars from multimodule project in master directory. Let us have a structure like this:
MASTER(pom)
|
+-A3(pom)
| +-A1(jar)
| +-A2(jar)
+-B3(pom)
+-B1(jar)
+-B2(jar)
我想要实现的是在MASTER中组装所有jar打包的模块.
What I want to achieve is to assembly all jar packaged modules in MASTER.
jars/
+- A1.jar
+- A2.jar
+- B1.jar
+- B2.jar
目前,我通过创建如下的pom.xml仅在子模块(A3和B3)上获得了良好的分辨率:
For now I achieved only good resolution on submodules (A3 and B3) by creating pom.xml like:
<modules>
<module>../A1</module>
<module>../A2</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
和程序集描述符:
<moduleSets>
<moduleSet>
<includes>
<include>org.mycompany:A1</include>
<include>org.mycompany:A2</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
<outputDirectory>jars/${artifactId}</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
当我这样做
mvn clean package assembly:assembly
分别在子模块(A3或B3)上,它们似乎可以很好地组装自己的子模块.
on submodules (A3 or B3) separately they seem to assembly their own submodules fine.
我不知道如何在MASTER中指定程序集描述符.类似于A3和B3描述符的那个不会处理([ERROR],您必须指定至少一个文件).我尝试了其他一些标签,例如includeSubModules ...仍然没有.
I don't know how to specify assembly descriptor in MASTER. The one similar to A3 and B3 descriptor does not deal with it ([ERROR] you must specify at least one file). I tried several additional tags like includeSubModules... still nothing.
推荐答案
承诺的分辨率(主装配体描述符):
Resolution as promised (Master Assembly Descriptor):
<moduleSets>
<moduleSet>
<binaries>
<includeDependencies>false</includeDependencies>
<outputDirectory>jars/${artifactId}</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
如您所见-像A3和B3一样,没有指向带有<include>
的特定模块
as you can see - no pointing to specific modules with <include>
like in A3 and B3
<includes>
<include>
(...)
</include>
</includes>
这确实很奇怪.不管怎么说.
this is strange indeed. Nevertheless working.
这篇关于Maven装配子模块多模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!