How to extract the JAR dependencies from a Maven project using M2E

If you need for one reason to extract all the JAR your Maven project is depending on, and you happen to be using M2E, use the following snippet in your pom.xml:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
       <execution>
         <phase>install</phase>
         <goals>
           <goal>copy-dependencies</goal>
         </goals>
         <configuration>
           <outputDirectory>${project.build.directory}/lib</outputDirectory>
         </configuration>
       </execution>
      </executions>
    </plugin>
  </plugins>
  <pluginManagement>
    <plugins>
      <plugin>
       <groupId>org.eclipse.m2e</groupId>
       <artifactId>lifecycle-mapping</artifactId>
       <version>1.0.0</version>
       <configuration>
         <lifecycleMappingMetadata>
           <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <versionRange>[2.0,)</versionRange>
                <goals>
                 <goal>copy-dependencies</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <execute />
              </action>
            </pluginExecution>
           </pluginExecutions>
         </lifecycleMappingMetadata>
       </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
</build>
Advertisements
This entry was posted in Java and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s