我已经使用 maven-assembly-plugin 在项目中实现了类似的功能。我希望在打包阶段构建一个 zip 文件,而不是手动调用 assembly:assembly。这是我想出的:
/src/assemble/distribution.xml:
<assembly>
<id>distribution</id>
<!-- specify the output formats -->
<formats>
<format>zip</format>
</formats>
<!-- include all runtime libraries in the /lib folder of the output file -->
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<!-- include all *.jar files in the target directory -->
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<!-- include all files in the /conf directory -->
<fileSet>
<outputDirectory></outputDirectory>
<includes>
<include>conf/**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
/pom.xml
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assemble/distribution.xml
</descriptor>
</descriptors>
</configuration>
<!-- append assembly:assembly to the package phase -->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
...