如何使用maven-assembly-plugin构建ZIP压缩文件时禁用压缩

问题描述:

我有一个由maven-assembly-plugin生成的ZIP压缩文件。它主要包含已压缩的JAR。再次压缩它们只会增加构建时间而没有任何收益。如何在构建ZIP存档时配置maven-assembly-plugin(或程序集描述符)以关闭压缩(即仅存储)?如何使用maven-assembly-plugin构建ZIP压缩文件时禁用压缩

在程序集插件配置中使用archiverConfig元素,将compress选项设置为false

例如

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <version>2.3</version> 
    <configuration> 
     <descriptors> 
      <descriptor>src/main/assembly/zip-application.xml</descriptor> 
     </descriptors> 
     <attach>true</attach> 

     <!-- Turn off compression --> 
     <archiverConfig> 
      <compress>false</compress> 
     </archiverConfig> 
    </configuration> 
    <executions> 
     <execution> 
      <id>create-zip</id> 
      <phase>package</phase> 
      <goals> 
       <goal>single</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin>