【问题标题】:How to Unzip arbitrary files using pom.xml in maven如何在maven中使用pom.xml解压任意文件
【发布时间】:2013-07-05 10:44:13
【问题描述】:

我在路径 "C:\ptc\Windchill_10.1\Windchill" 中有一个 zip 文件。请谁能告诉我如何使用 maven 解压缩此文件

【问题讨论】:

    标签: maven unzip


    【解决方案1】:

    Maven 有一个插件可以与 Ant 一起工作。使用该插件,您可以创建 Ant-Tasks,这些任务是一系列 xml 指令,您可以使用(实际上)任何您需要的东西。

    一段可以作为灵感的代码:

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

    来源:https://ant.apache.org/manual/Tasks/unzip.html

    【讨论】:

      【解决方案2】:

      Maven有一个名为dependency plugin的插件,可以帮助你处理工件,你可以查看文档here

      如果您的要求是解包依赖项及其传递依赖项,请查看here

      您也可以查看问题here提供的解决方案

      【讨论】:

      • 很明显 galme 不是指依赖,所以这不是一个解决方案。已经有很多问题专门用于解压缩依赖项,但很少有问题涉及在给定路径上解压缩文件。
      • @Mitch 我提到解压缩依赖项的原因是因为 op 提到的文件夹是 Windchill 产品通常保存 jar 文件的位置。我意识到 op 正在尝试打开这些 jar 文件,因此我在这个方向上的答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 2014-08-20
      • 2017-02-03
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多