Unzip dependency in maven

Shervin Asgari picture Shervin Asgari · Mar 22, 2011 · Viewed 34.8k times · Source

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>

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.

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?

Answer

Sean Patrick Floyd picture Sean Patrick Floyd · Mar 22, 2011

You can do it with 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>

Reference: