maven-2 - 在 maven 中解压依赖

标签 maven-2 maven zip sigar

我在 maven 中有以下依赖项

<dependency>
  <groupId>org.hyperic</groupId>
  <artifactId>sigar-dist</artifactId>
  <version>1.6.5.132</version>
  <type>zip</type>
</dependency>

这将创建 sigar-dist-1.6.5.132.zip在我的存储库中。
我见过这个 question here ,但是我仍然无法使其工作。

如何解压缩 sigar-dist.zip 并将内容放在我的项目的目录中?我必须执行什么 mvn 调用才能使其工作?

最佳答案

你可以用 dependencies:unpack-dependencies 来做:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.2</version>
    <executions>
      <execution>
        <id>unpack-sigar</id>
        <phase>package<!-- or any other valid maven phase --></phase>
        <goals>
          <goal>unpack-dependencies</goal>
        </goals>
        <configuration>
          <includeGroupIds>org.hyperic</includeGroupIds>
          <includeArtifactIds>sigar-dist</includeArtifactIds>
          <outputDirectory>
             ${project.build.directory}/wherever/you/want/it
             <!-- or: ${project.basedir}/wherever/you/want/it -->
          </outputDirectory>
        </configuration>
      </execution>
    </executions>
</plugin>

引用:
  • Unpacking project dependencies
  • dependency:unpack-dependencies
  • 关于maven-2 - 在 maven 中解压依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5388661/

    相关文章:

    Powershell Web请求无法正确下载文件

    maven-2 - 配置 Maven 在项目目录外生成输出

    maven - Maven 项目中的 Jar 签名策略

    java - Maven 模块 + 构建单个特定模块

    java - Intellij IDEA 2017.2 无法解析符号

    python - 如何使用 Python 2.4 解压缩文件?

    java - Maven,稳定性,用v3还是用v2?

    java - 使用 Eclipse 和 Maven 时缺少 tools-1.6.jar

    java - 如何获取项目的/资源文件夹中文件的绝对路径