Search code examples
mavenzipmaven-2archiveunzip

Unpack inner zips in zip with Maven


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 well. How can I do this?


Solution

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