使用Maven创建一个ZIP存档 [英] Create a ZIP archive with Maven

查看:101
本文介绍了使用Maven创建一个ZIP存档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了有关如何在Maven中创建ZIP存档的答案: https://stackoverflow.com/a/2514677/1395165 并有几个后续问题:

I followed the answer for how to create a ZIP archive in Maven here: https://stackoverflow.com/a/2514677/1395165 and have a couple of follow-up questions:

ZIP内容以排除目录:

在示例中,我有:

<fileSet>
    <directory>${project.basedir}/src/export</directory>
    <useDefaultExcludes>true</useDefaultExcludes>
</fileSet>

在ZIP中,我得到

src
  export
     Dir1
     Dir2

但我只想拥有

Dir1
Dir2 

ZIP中的

.有可能吗?

in the ZIP. Is that possible?

输出文件名

以.zip扩展名创建输出文件名.在Maven中是否可以将扩展名覆盖到其他扩展名(例如.abc)?

The output file name is created with a .zip extension. Is it possible in Maven to override the extension to something else (say .abc)?

推荐答案

outputDirectory选项可用于更改文件输出到的程序集中的目录-这应该满足您的要求:

The outputDirectory option can be used to change the directory within the assembly that the files are output to - this should do what you need:

<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>
<formats>
    <format>zip</format>
</formats>
<fileSets>
    <fileSet>
        <directory>${project.basedir}/ScriptedBuild/rConnect/extract/</directory>
        <useDefaultExcludes>true</useDefaultExcludes>
        <outputDirectory>/</outputDirectory>
    </fileSet>
</fileSets>
</assembly> 

这篇关于使用Maven创建一个ZIP存档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆