在 maven 中解压依赖 [英] Unzip dependency in maven

查看:48
本文介绍了在 maven 中解压依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 maven 中有以下依赖

I have the following dependency in 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.我在这里看到了这个问题,但我仍然无法让它工作.

This creates sigar-dist-1.6.5.132.zip in my repository. I have seen this question here, however I still can't make it work.

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

How can I unzip the sigar-dist.zip and place the content in a directory in my project? What is the mvn call I have to do to make it work?

推荐答案

你可以用 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>

参考:

这篇关于在 maven 中解压依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆