创建行家“目标"的zip档案.目录 [英] Creating a zip archive of the maven "target" directory
问题描述
我希望为我的目标"目录($ {project.build.directory)创建一个zip存档.在我看来,使用maven-assembly-plugin对于这样一个简单的任务似乎有点过头(而且有点复杂-为什么我必须为该任务使用另一个文件,即程序集描述符) 我找不到看似更简单的 maven-zip -a插件在 http://repo1.maven.org/maven2 存储库中.
I wish to create a zip archive of my "target" directory (${project.build.directory). using the maven-assembly-plugin seems to me like overkill for such a simple task (and a bit complicated - why must I use another file, the assembly descriptor, for such a task) I can't locate the seemingly more simple maven-zip-plugin in the http://repo1.maven.org/maven2 repository.
有输入吗?
推荐答案
如果 bin
预定义的程序集描述符不符合您的需求,那么您有三个选择:
If the bin
predefined assembly descriptor doesn't suit your needs, then you have three options:
- 使用maven-assembly-plugin-从来没有出现过maven-zip-plugin,因为Assembly插件可以完成zip插件正在做的所有事情,更多信息,请参见此处(这比最后的Assembly插件更冗长).
- 编写您自己的插件-当您拥有程序集插件时为什么要这么做?
- Using the maven-assembly-plugin - The maven-zip-plugin never came out because the assembly plugin can do everything the zip plugin was doing, and more, see MNG-2243.
- Using the maven-antrun-plugin (and maybe the build-helper-plugin to attach the zip) - There is an example here (and this looks more verbose than the assembly plugin at the end).
- Writing your own plugin - why would you do this when you have the assembly plugin.
就我个人而言,我将使用带有以下zip.xml
描述符的maven-assembly-plugin:
Personally, I would just use the maven-assembly-plugin with the following zip.xml
descriptor:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
</fileSet>
</fileSets>
</assembly>
在您的POM中:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
这篇关于创建行家“目标"的zip档案.目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!