Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How extract all the jars needed for a maven project to a folder?

Tags:

maven

jar

I’m trying to de-mavenize a project.

Is there a way to extract all the jars needed for this maven project to a folder?

(I’m very newbie with maven, so please; instructions provided should be in dummy mode) Thanks!

;-)

like image 214
JLLMNCHR Avatar asked Apr 24 '12 08:04

JLLMNCHR


People also ask

Where are JARs stored in maven project?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.

How do I export a maven project as a runnable jar?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.


2 Answers

You can use dependency:copy-dependencies goal of maven dependency plugin to achieve this.

In fact, just run mvn dependency:dependencies on your maven project and you should find a dependencies subfolder created under target folder and populated with all the dependencies including transitive ones.

like image 161
Raghuram Avatar answered Sep 22 '22 00:09

Raghuram


Take a look at maven-assembly-plugin and its jar-with-dependencies predefined descriptor:
http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies

You can easily create own descriptor by modify this one slightly. Just set <unpack>false</unpack> and <outputDirectory>/some-dir</outputDirectory>.

And if you haven't used this plugin so far, read this:
http://maven.apache.org/plugins/maven-assembly-plugin/usage.html
to get what's actually going on there and how to use it.

like image 42
Michał Kalinowski Avatar answered Sep 22 '22 00:09

Michał Kalinowski