copy Maven dependencies to a target folder

May 3, 2012. Posted by Andy Hulstkamp under Configuration Java Maven

Reminder to myself: If you can’t get Maven to work with a particular IDE or plug-in it might be helpful to at least copy all dependencies (jars) to a destination-folder. The Maven Dependency Plug-In will kindly assist you to copy maven dependencies to a target folder.

Include the plugin:

 <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>${project.build.directory}/alternateLocation</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>false</overWriteSnapshots>
          <overWriteIfNewer>true</overWriteIfNewer>
        </configuration>
      </execution>
    </executions>
  </plugin>

Invoke

mvn dependency:copy-dependencies

to copy all the dependencies of a project to the specified target folder.

mvn dependency:copy-dependencies -Dclassifer=sources

will copy all sources.

mvn dependency:analyze

shows information about used and unused declared dependencies.

mvn dependency:tree

gives an overview of the nested dependencies.



Share/Save/Bookmark

Comments are closed.