Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 925
khmarbaise Avatar asked Jul 16 '10 10:07

khmarbaise


2 Answers

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> 
like image 74
Boris Pavlović Avatar answered Sep 23 '22 03:09

Boris Pavlović


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

like image 29
MariuszS Avatar answered Sep 20 '22 03:09

MariuszS