首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Maven解压内拉链

用Maven解压内拉链
EN

Stack Overflow用户
提问于 2010-07-16 18:51:00
回答 4查看 35K关注 0票数 38

我可以通过maven-dependency插件解压zip文件,但是目前我有一个问题,在这个zip文件中包含了其他的zip文件,我也需要解压它们。我该怎么做呢?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-07-16 19:06:13

你可以使用ant task runner插件解压任何文件:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>prepare</id>
            <phase>validate</phase>
            <configuration>
                <tasks>
                    <echo message="prepare phase" />
                    <unzip src="zips/archive.zip" dest="output/" />
                    <unzip src="output/inner.zip" dest="output/" />
                    <unzip dest="output">
                      <fileset dir="archives">
                        <include name="prefix*.zip" />
                      </fileset>
                    </unzip>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
票数 43
EN

Stack Overflow用户

发布于 2011-10-04 20:55:42

使用ANT再也不酷了;)

http://maven.apache.org/plugins/maven-dependency-plugin/examples/unpacking-artifacts.html

解压zip (archive.zip)文件的示例代码:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>process-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>foo</groupId>
                        <artifactId>archive</artifactId>
                        <version>1.0-SNAPSHOT</version>
                        <type>zip</type>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

文件archive.zip应该首先安装到maven存储库中。例如,使用任务Attach artifact org.codehaus.mojo:build-helper-maven-plugin:build-helper:attach-artifact

票数 24
EN

Stack Overflow用户

发布于 2015-05-27 21:50:45

TrueZIP Maven Plugin也运行得很好。示例配置:

代码语言:javascript
复制
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>truezip-maven-plugin</artifactId>
    <version>1.2</version>
    <executions>
        <execution>
            <id>copy-package</id>
            <goals>
                <goal>copy</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <verbose>true</verbose>
                <fileset>
                    <directory>outer.zip</directory>
                    <outputDirectory>${project.build.directory}/outer</outputDirectory>
                </fileset>
                <fileset>
                    <directory>${project.build.directory}/outer/inner.zip</directory>
                    <outputDirectory>${project.build.directory}/inner</outputDirectory>
                </fileset>
            </configuration>
        </execution>
    </executions>
</plugin>

Official examples

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3264064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档