How to Unzip arbitrary files using pom.xml in maven

galme picture galme · Jul 5, 2013 · Viewed 15.1k times · Source

I have a zip file in the path "C:\ptc\Windchill_10.1\Windchill" . Please can anyone tell me how to unzip this file using maven

Answer

Sergio picture Sergio · Jun 7, 2016

Maven has a plugin to work with Ant. With that plugin you can create Ant-Tasks, this tasks are a sequence of xml instructions that you can use to (virtually) anything you need.

A piece of code that you can use as inspiration:

<plugins>
   <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.8</version>
      <executions>
         <execution>
            <phase>generate-resources</phase>
            <configuration>
               <tasks>
                  <echo message="unzipping file" />
                  <unzip src="output/inner.zip" dest="output/" />
               </tasks>
            </configuration>
            <goals>
               <goal>run</goal>
            </goals>
         </execution>
      </executions>
   </plugin>
</plugins>

source: https://ant.apache.org/manual/Tasks/unzip.html