【发布时间】:2015-09-16 13:05:47
【问题描述】:
我在构建项目时使用 maven-assembly-plugin 创建项目的 zip 文件。这是成功的。现在我想要的是仅压缩项目中的特定目录。
这是我之前使用的 pom 中插件的代码。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make shared resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>resource.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
而resource.xml文件如下。
<assembly>
<id>resources</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<!-- Since it bundles all the units -->
<directory></directory>
<outputDirectory>/project</outputDirectory>
<excludes>
<exclude>pom.xml</exclude>
<exclude>*.iml</exclude>
<exclude>*.jar</exclude>
<exclude>**/src/**</exclude>
<exclude>**/target/**</exclude>
<exclude>resource.xml</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
我只想压缩 maven 构建中项目的一些目录。
作为一个例子,我在项目中有以下文件夹结构。
project
|_directories
|_dir1
|_ ....
|_dir2
|_ ....
|_dir3
|_ ....
|_pom.xml
我想要的是制作只包含目录文件夹的 zip 文件。提取我的 zip 文件时,它应该只包含其中的四个目录。
我怎样才能做到这一点? maven-assembly-plugin 是否足以做到这一点,还是我应该创建一个 mojo?
【问题讨论】:
-
您是否尝试过使用
include标签明确命名您想要的目录? maven.apache.org/guides/mini/guide-assemblies.html -
你确定 pom.xml 是在
directories而不是project
标签: maven maven-assembly-plugin