Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unzip dependency in 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> 

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?

like image 483
Shervin Asgari Avatar asked Mar 22 '11 08:03

Shervin Asgari


People also ask

What is unpack in maven?

org.apache.maven.plugins:maven-dependency-plugin:3.3.0:unpack. Description: Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.

What is maven war plugin?

The Maven WAR plugin is responsible for collecting and compiling all the dependencies, classes, and resources of the web application into a web application archive. There are some defined goals in the Maven WAR plugin: war: This is the default goal that is invoked during the packaging phase of the project.

What is a maven classifier?

A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact's name just after its version number. It distinguishes the artifacts built from the same POM but differing in content.


1 Answers

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:

  • Unpacking project dependencies
  • dependency:unpack-dependencies
like image 73
Sean Patrick Floyd Avatar answered Sep 28 '22 02:09

Sean Patrick Floyd