How to Unzip arbitrary files using pom.xml in maven

时光总嘲笑我的痴心妄想 提交于 2020-02-27 19:09:45

问题


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


回答1:


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




回答2:


Maven has a plugin named dependency plugin which helps you deal with artifacts, you can check documentation here

If your requirement is to unpack the dependencies and their transitive dependencies, take a look here

You can also take a look at solution provided in question here



来源:https://stackoverflow.com/questions/17487023/how-to-unzip-arbitrary-files-using-pom-xml-in-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!