作为打包应用程序(war / jar)的一部分,我想将应用程序的所有配置打包为zip文件。是否有maven中的约定或插件可以轻松实现此目的?
答案 0 :(得分:3)
创建一个程序集文件,例如assembly.xml,其中包含您要打包的文件详细信息。然后在pom.xml中配置assembly.xml文件,如下所示。
<强> assembly.xml 强>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>project-name</id>
<formats>
<format>
zip
</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>project/config</outputDirectory>
<directory>${project.basedir}/src/main/resources/config</directory>
<!--To include single file into the zip -->
<includes>
<include>singlefile.conf</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<强>的pom.xml 强>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>