Q:

Aggregate Dependencies in a Multi-Module Maven Project

I am trying to figure out how to aggregate my maven dependencies in a multi-module project.  For example, if I have:
root pom/project1
root pom/project2

and I run mvn dependency:copy-dependencies, I end up with the dependencies in:
root pom/project1/target/dependency
root pom/project2/target/dependency

What I really want is that if I run the mvn command in the root pom folder, all of the dependencies to be copied to root pom/dependency.  Is there a maven property that gets me the output directory of the root pom? (similar to ${project.build.directory})?  I realize that I can just copy all the dependency folders to the same place after the fact, but I was hoping for something a little cleaner.

A:

You will have to configure the dependency plugin to copy depdendencies to a particular location. This can be done by the outputDirectory configuration property.
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
      <execution>
         <id>copy-dependencies</id>
         <phase>package</phase>
         <goals>
            <goal>copy-dependencies</goal>
         </goals>
         <configuration>
              <outputDirectory>${outputDir}</outputDirectory>
         </configuration>
      </execution>
   </executions>
</plugin>

But if you trying to do this for distribution, I'd recommend you create an assembly using the maven assembly plugin
The documentation says:
The Assembly Plugin for Maven 2.0 is primarily intended to allow users to aggregate the
project output along with its dependencies, modules, site documentation, and other files
into a single distributable archive.

