Unpack inner zips in zip with Maven

前端 未结 4 1212
广开言路
广开言路 2020-11-30 04:59

I can unpack zip file via the maven-dependency plugin, but currently I have the problem that inside that zip file other zip files are include and I need to unpack them as we

相关标签:
4条回答
  • 2020-11-30 04:59

    TrueZIP Maven Plugin also works well. Sample config:

    <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

    0 讨论(0)
  • 2020-11-30 05:08

    You can unzip any files using ant task runner plugin:

    <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>
    
    0 讨论(0)
  • 2020-11-30 05:18

    You can also use the plugin dependencies. There is a goal to unpack dependencies (see http://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html)

    0 讨论(0)
  • 2020-11-30 05:25

    Using ANT is not cool any more ;)

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

    Sample code for unpacking zip (archive.zip) file:

    <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>
    

    File archive.zip should be installed into maven repository first. For example with task Attach artifact org.codehaus.mojo:build-helper-maven-plugin:build-helper:attach-artifact

    0 讨论(0)
提交回复
热议问题