This question already has answers here:
Differences between dependencyManagement and dependencies in Maven
(15 answers)
Closed 6 years ago.
I already create a jar that contain some common jars, which we will use it in different applications and can be used via many users.
To Solve this, i create a common jars, so i can control this commons jars and version of them, then store it in nexus server, so it can contain the parent pom and can be used by many developers.
So i create a simple maven java application and in the pom of this jar, i put for example :
Parent pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.emp</groupId>
<artifactId>dependencymanager</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Then in the child applications i use this jar like this:
<dependencies>
<dependency>
<groupId>com.emp</groupId>
<artifactId>dependencymanager</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
But when i try to use org.primefaces, i can't. Where i'm wrong, or i'm wrong in the implementation of dependency management?
Note
I already read this : http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
So in the example of this tutorial it not specify the version of the parent pom, so when i delete it show me an error like this :
'dependencies.dependency.version' for com.emp:dependencymanager:jar is missing.
Question
How can i implement dependency management in this case?
Is there any better way then this to work with same dependencies with
many projects and many devellopers.
I use nexus to store my jars
Thank you.
In the parent pom, add the dependencies directly, leaving out the dependencyManagement tags. With the dependencyManagement you only specify that if such a dependency is declared in your pom, that the version specified in the parent pom is to be used. But your parent pom does not per se include those dependencies as transitive dependencies.
I have used Maven Shade plugin for having dependencies in the generated jar file. Check if similar code works for you
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Related
There is a class in a maven dependency that is incompatible with Java 8.
How do you properly fix that problem?
Right now I'm doing the following:
Create a package with the same name
Create a class with the same name in that package
Copy and paste the code
Fix the incompatible API call
The problem is that this class contains API calls to restricted classes and although I changed the Eclipse compiler settings (Window -> Preferences -> Java -> Compiler -> Error/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule): Error -> Warning) to allow access the project will only compile sometimes. If it doesn't compile I'll get a "can't find symbol" error.
Edit:
Here are the details you asked for:
Dependency: http://mvnrepository.com/artifact/com.sun.xml.wss/xws-security/3.0
Class: EncryptionProcessor
Necessary change:
// Change line 1053 FROM:
// _dataEncryptor = XMLCipher.getInstance(dataEncAlgo, _dataCipher);
// TO:
_dataEncryptor = XMLCipher.getInstance(dataEncAlgo);
Edit-2:
Maven build error:
[ERROR] symbol: class XMLCipher
[ERROR] location: class com.sun.xml.wss.impl.apachecrypto.EncryptionProcessor
[ERROR] /C:/Users/{name}/development/eclipse_workspace/git/xws-security/src/main/java/com/sun/xml/wss/impl/apachecrypto/EncryptionProcessor.java:[1482,98] cannot find symbol
Here is a detailed guide describing what I did exactly:
Create new Maven project in Eclipse
Configure Maven settings of new project (Important: Use the same group and artifact ID and only change the version number)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun.xml.wss</groupId>
<artifactId>xws-security</artifactId>
<version>3.0-java8-fix</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
</project>
Add dependency of bugged JAR
<dependencies>
<dependency>
<groupId>com.sun.xml.wss</groupId>
<artifactId>xws-security</artifactId>
<version>3.0</version>
<exclusions>
<exclusion>
<artifactId>xmldsig</artifactId>
<groupId>javax.xml.crypto</groupId>
</exclusion>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Create Java file in the same package of class that needs to be fixed
package com.sun.xml.wss.impl.apachecrypto;
public class EncryptionProcessor {
// The FIX goes here
}
Add Maven shade build plug in to handle creation of patched JAR file (this is not the only plug in to handle this kind of task - e.g. dependency:unpack)
<build>
<plugins>
<!-- plug in for creation of patched JAR file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.sun.xml.wss:xws-security:3.0</artifact>
<includes>
<include>**/*.class</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exlude>
com/sun/xml/wss/impl/apachecrypto/EncryptionProcessor.class
</exlude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Include patched JAR in other projects as necessary (Note: If you experience ClassNotFoundExceptions or similar errors do this: Right-click on the project -> Properties -> Maven -> "Resolve dependencies from Workspace projects":false)
In case you are not familiar with Maven. Here is the complete pom.xml: http://pastebucket.com/88444
Similar to Steven S.'s answer, but using the maven-dependency-plugin. Based on this blog post.
I changed the name of the patched library (not the version), but it depends on your needs what works better for you.
The dependency on the original library should be marked as <optional>true</optional>. Otherwise, the projects that depend on your patched library will also depend on the original library, which means that both the patched and the original version will be on the classpath, which can lead to all kinds of problems.
If your project is a child project, you can still use a completely different groupId and version than your parent pom. Doesn't matter.
You can exclude the classes you patch from unpacking, but it's probably not necessary, because Maven will first unpack the original library and then compile your new version, which means that the original classes are overwritten. Nice!
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<!-- remove this if you don't have a parent pom -->
<parent>
<groupId>my.company</groupId>
<artifactId>my.company</artifactId>
<version>1.2.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.foo</groupId>
<artifactId>foo-bar-patched</artifactId>
<version>4.5.6</version>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<!-- excludes are probably not necessary -->
<!-- <excludes>**/Foo.class,**/Bar.class</excludes> -->
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<version>4.5.6</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
General solution:
download all project sources
apply your modification
use version control so that change isn't lost
change version in pom.xml, for example from 3.0 to 3.0-patched
launch maven build
copy generated artifacts to you repository/Artifactory, if you use one
change dependency version in your own project
I have an Eclipse Maven Project (parent) that hosts three Maven MODULES (it's children). Only the child MODULES have code under "src/main/java/..." (i.e. the PARENT is just a stub place holder for the children).
Each MODULE is independent of one another... I just set it up that way to reduce clutter. =:)
Now the project structure didn't start out this way. Initially it was just one big PARENT and no child MODULES; and everything worked fine. But then I reorganized things within Eclipse (again to reduce clutter) using various moves/refactors, and things stopped working.
The Problem: My source code can't find imported classes now, so my dependency resolution became problematic somewhere. And the problem isn't just seen in Eclipse, but also when I run, say, 'mvn clean install' from the CLI. So I suspect something is wrong with the set of POM files that resulted from my moves/refactors.
Here they are (the PARENT and one CHILD). Am I missing something, or is something incorrect? Maybe I should check something Eclipse, too?
Note that I embedded a couple of little in-line questions inside the POM files below. :)
The PARENT pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>someName</name>
<packaging>pom</packaging>
<groupId>someParentGroupId</groupId>
<artifactId>someParentArtifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<jdk.version>1.7</jdk.version>
<example-core.version>0.9.3</example-core.version>
<!-- Intended to be used by some Child/Module.
I hope PARENT/CHILD POM inheritance works that way? -->
</properties>
<dependencies>
<!-- Dependencies are all in the Children/Modules -->
</dependencies>
<!-- ################### BUILD SETTINGS BEGIN ##################### -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin> <!-- Used to create an UBER/FAT-JAR. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>uber-${project.artifactId}-${project.version}</finalName>
</configuration>
</plugin>
</plugins>
</build>
<!-- ################### BUILD SETTINGS END ####################### -->
<modules>
<module>childModule1</module>
<module>childModule2</module>
<module>chileModule3</module>
</modules>
</project>
Example CHILD pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>someParentGroupId</groupId>
<artifactId>someParentArtifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>someChildArtifactId</artifactId>
<!-- I noticed this missing in the Children/Module POM. Is that okay?
<name>
</name>
-->
<dependencies>
<dependency>
<groupId>org.example.somgGroupId</groupId>
<artifactId>example-core</artifactId>
<version>${example-core.version}</version>
</dependency>
</dependencies>
</project>
Again, the problem seems simple. I can't resolve imports (so, naturally, my Classes have import-ralated errors).
Thank you in advance!
name is not a mandatory attribute in pom.xml.
I assume someChildArtifactId is given as an example. If not, the same artifact id should be used in the parent pom.
I am looking for a way to include all the modules in a project from another pom.xml. So in my case I have a parent pom with packaging set to pom. It contains 3 child modules that implement my interfaces in another api module. I want to dynamically include all the child modules in my project in maven.
In this case I want to include the connector1, connector2, connector3 in another module without having to specifiy the connector1,2,3 implicitly.
connectors - packaging: pom
connector1 - packaging: jar
connector2 - packaging: jar
connector3 - packaging: jar
I tried including the connectors pom in my project but this did not work. I was hoping that specifying the parent package with pom would include the child modules but this did not work. Are there any workarounds for how to do this?
Update
This was more of peeve of mine because I wanted to simply add a single connector and have all the child module dependency jars for the project be included. This would make the pom a little simpler to read.
Instead of having to register all the child dependencies like so
<dependencies>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1-api</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1-etl</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1-persistence</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2-api</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2-etl</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2-persistence</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2-other</artifactId>
<version>0.0.1</version>
</dependency>
...
</dependencies>
This is just an example to clarify the original question. It does not exist and would probably have reprocussions if it did work.
<dependencies>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1</artifactId>
<version>0.0.1</version>
<type>pom</type>
<include>submodules</include>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector2</artifactId>
<version>0.0.1</version>
<type>pom</type>
<include>submodules</include>
</dependency>
</dependencies>
If I remember correctly I was creating a modular project for an ordering system where I had a common api that our internal system would use (REST). I was creating a routing system where I could route an order to a single fulfillment center based on a criteria of the order (country, priority taxes etc). Each of the fulfillment centers had their own api (connectors).
The example is greatly simplified in the original question to make it more the problem more concise. In the real project each connector (1,2,3) would have been a separate pom with multiple dependency jars. One for their client api, then some etl code to match with my original api.
I don't remember how I solved this. I think I just had to include the all the child dependencies.
One way is to create a fourth module which "wraps" the 3 modules as dependencies. This way you could depend on this wrapper module which would.
connectors - packaging: pom
connector1 - packaging: jar
connector2 - packaging: jar
connector3 - packaging: jar
connectorWrapper - packaging: pom (depends on the above three)
Although it would make more sense to explicitly declare a dependency for each connector especially that they are only three.
Alternative solution:
A more dynamic approach (although very much an overkill IMO) is to have this fourth module package the implementation modules in an assembly using a custom assembly descriptor. For example, inside connectorWrapper, you could write an assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>impl-modules</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<includes>
<include>pom.xml</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>*:connector*</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
Note that the descriptor tells the assembly plugin to:
include all modules in the current project reactor, so when you run mvn clean package in the root project, it will include all modules
include only implementation modules (the connector modules), as specified in the include element having *:connector*.
Of course you'll need to configure the assembly plugin to use this descriptor in the connectorWrapper (or whatever other name you choose for this wrapper):
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Then you can run mvn install on the root project to install the assembly artifact, after which you can depend on it from the other project:
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>connectorWrapper</artifactId>
<version>...</version>
<classifier>impl-modules</classifier> <!-- note the classifier -->
</dependency>
</dependencies>
Not entirely sure whether it exactly does what you need but within the latest maven releases you can use the scope import on your dependencies.
The first step would be to create a pom containing all the dependencies you would like to include in other projects:
<project>
<groupId>com.foo</groupId>
<artifactId>connectors</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1-api</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.foo</groupId>
<artifactId>connector1-etl</artifactId>
<version>0.0.1</version>
</dependency>
...
</dependencies>
</project>
In the projects you would like to include the connectors you have:
<dependency>
<groupId>com.foo</groupId>
<artifactId>connectors</artifactId>
<version>0.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
See Importing Dependencies for more information.
An alternative approach could be to use the maven assembly plugin and create a single (huge) jar containing all the classes you would like to include (single jar packaging); (for that you also need to create once a pom with all the dependencies and the assembly plugin).
I would write my own maven plugin for this. Judging from your reputation and the question, you could probably have something ready within the hour. Most probably sooner than researching and trying out solutions to do what you want.
I am working on a project which contains a number of subprojects. The structure is something like Project 1, Project 2 and ProjectClassLoader.
Using separate configuration files, I pass in the binary names of the classes from Projects 1 and 2 that need to be loaded each time as arguments to the ProjectClassLoader project.
The ProjectClassLoader gets a handle to the system classloader
ClassLoader loader = ClassLoader.getSystemClassLoader();
which in theory allows it to load any classes which are contained in the classpath.
I'm using Maven to build the projects and handle their associated dependences. Thus each project has it's own individual pom.xml file. The ProjectClassLoader defines a parent pom.xml over Projects 1 and 2 which inherit from this. The parent pom contains dependency entries for both Project 1 and 2.
My understanding was that any dependencies specified in the pom.xml files of these projects would get added to the classpath at runtime. However when trying to load classes using the system classloader, I'm getting class not found execptions.
I have tried using the mvn:exec plugin which I understand includes the dependencies in the classpath when executing jars on the command line but this has not worked.
I'd grately appreciate any help in furthering my understanding of why I can load the classes even though the dependencies are defined in the pom...Thanks in advance
Can you check if your pom matches this configuration a bit?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<properties>
...
<exec.maven.plugin.version>1.2.1</exec.maven.plugin.version>
...
</properties>
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
...
</plugins>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.maven.plugin.version}</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies, also adding the project build directory -->
<classpath />
<argument>com.example.Main</argument><!-- your mainClass -->
</arguments>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
<dependencies>
...
<dependency>
<groupId>groupId.for.project1</groupId>
<artifactId>project1</artifactId>
</dependency>
<dependency>
<groupId>groupId.for.project2</groupId>
<artifactId>project2</artifactId>
</dependency>
...
</dependencies>
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>groupId.for.project1</groupId>
<artifactId>project1</artifactId>
<version>${project1.version}</version>
</dependency>
<dependency>
<groupId>groupId.for.project2</groupId>
<artifactId>project2</artifactId>
<version>${project2.version}</version>
</dependency>
...
</dependencies>
</dependencyManagement>
...
</project>
Where you fill them with the correct artifacts.
You should then be able to start it with:
mvn exec:exec
Can you post your configuration for your pom plz if it doesn't match, that way it's easier to understand what exactly you currently have in your pom.
I used the maven assembly package to create a single monolithic jar. Included is the datanucleus package, but I am getting errors because I did not maintain the OSGI structure (plugins.xml & META-INF/META-INF.MD). The answers on stackoverflow([question]: Datanucleus, JDO and executable jar - how to do it?) do not provide answers on how to create the single deployable jar.
Does anyone know what maven directives I can use to ensure OSGI structure?
So, the problem is that packing everything into a monolithic jar is that the OSGI structures get overritten by the OSGI structure of other jars. The benefit of the monolithic jar was to have a single file to push to the server but not necessary (since I was using capistrano to push to the server)
Instead, it's easier to just copy the jars into the final build directory. Heroku's Java setup has a perfect example of this:
https://devcenter.heroku.com/articles/java
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.0.v20120127</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>