[英]How to create a zip file of a specific directory in maven?
maven 程序集插件可以创建任何你想要的 zip 文件。 文档非常好,您可以在此处查看示例。
它的要点是添加一个描述如何组装文件的 xml 文件,然后从 pom.xml 中引用它。 这是程序集描述符的示例(取自网站):
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>README.txt</source>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>LICENSE.txt</source>
<outputDirectory></outputDirectory>
</file>
<file>
<source>NOTICE.txt</source>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>
然后在pom.xml
中,您将像这样引用此文件(假设该文件在assembly
目录下名为distribution.xml
):
<project>
[...]
<build>
[...]
<plugins>
[...]
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</plugin>
[...]
</project>
还有更多选项可以帮助您过滤掉文件或包含/排除目录等。 全部在文档中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.