只需使用“dir”格式的Maven Assembly 插件将它们全部放在一个文件夹中,并使用“jar”格式将它们分组到一个 jar 中。
更多细节:
- 您从您的 Maven 项目开始(我们称它们为子项目)
- 创建一个新的maven项目(pom打包),使用<module>标签聚合所有子项目
- 将程序集插件放入您的 pom.xml 文件中(见下文)
- 创建正确的 assembly.xml 文件(见下文)
pom.xml 文件:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>somefolder</finalName>
<attach>false</attach>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<phase>package</phase>
</configuration>
</execution>
</executions>
</plugin>
组装.xml 文件:
<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>SomeName</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory></baseDirectory>
<fileSets>
<fileSet>
<directory>appfiles</directory>
<includes>
<include>**</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<!-- useAllReactorProjects must be false if the assembly's run on the project with the module list -->
<useAllReactorProjects>false</useAllReactorProjects>
<includeSubModules>false</includeSubModules>
<binaries>
<includeDependencies>true</includeDependencies>
<outputDirectory>bundle</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>