您可以使用Maven Assembly Plugin来构建罐子。
首先,你需要一些信息添加到您的pom.xml 插件部分,使产生的JAR可执行文件:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.example.installer.Installer</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
我建议使用一个单独的assembly descriptor构建实际的安装程序罐。这里有一个例子:
<assembly>
<id>installer</id>
<formats>
<format>jar</format>
</formats>
<baseDirectory></baseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<!-- this references your installer sub-project -->
<include>com.example:installer</include>
</includes>
<!-- must be unpacked inside the installer jar so it can be executed -->
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<!-- this references your server.war and any other dependencies -->
<include>com.example:server</include>
</includes>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
如果您保存了装配描述为“installer.xml”你可以通过运行这样的组件构建的jar:
MVN清洁套装组件:单-Ddescriptor = installer.xml
希望这会有所帮助。以下是你可能会发现一些有用的链接: