~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ------ Copying specific artifacts ------ Allan Ramirez Brian Fox Stephen Connolly ------ 2011-07-01 ------ Copying specific artifacts In copying specific artifacts, you need to bind the <<>> mojo to a lifecycle, configure the plugin and specify the artifacts you want to copy. See the following example: +---+ [...] org.apache.maven.plugins maven-dependency-plugin ${project.version} copy package copy junit junit 3.8.1 jar false \${project.build.directory}/alternateLocation optional-new-name.jar \${project.build.directory}/wars false true [...] +---+ Then after executing <<>>, the artifact (junit) is copied to the given alternate location. Artifacts are resolved from the following sources in order: * the current reactor, * the local repository, * the configured remote repositories. [] If the artifact cannot be resolved from the above sources then the build will fail. If the artifact is also listed as a dependency, the <<>> of the <<>> will default to the version from the <<>> or <<>>, e.g. +---+ [...] junit junit 3.8.1 test [...] org.apache.maven.plugins maven-dependency-plugin ${project.version} copy package copy junit junit false \${project.build.directory}/alternateLocation optional-new-name.jar \${project.build.directory}/wars false true [...] +---+ The <<>> goal can also be used to copy the just built artifact to a custom location if desired. <> so that the artifact exists in the repository. The following configuration shows how (binding to the install phase in this case): +---+ [...] org.apache.maven.plugins maven-dependency-plugin ${project.version} copy-installed install copy \${project.groupId} \${project.artifactId} \${project.version} \${project.packaging} some-other-place [...] +---+ {Using an alternate local repository} <> always downloads artifacts to default local repository first, and then copy the artifacts to the desired locations. For large size unique snapshot artifacts, the downloads can quickly fill up default local repository, and therefore local disk, after many executions. To clean up the downloaded artifacts as part the build, set 's value to a location in your project's target directory. This use case also applies to <> goal. +---+ [...] org.apache.maven.plugins maven-dependency-plugin ${project.version} copy-with-alternalte-repo install copy [...] [...] \${project.build.directory}/localrepo [...] +---+ {Copying from the command line} If you intend to configure this mojo for execution on the command line using: +---+ mvn dependency:copy +---+ you must not put the configuration inside the tag. Your configuration should look like this: +---+ [...] org.apache.maven.plugins maven-dependency-plugin ${project.version} [ groupId ] [ artifactId ] [ version ] [ packaging ] [ true or false ] [ output directory ] [ filename ] [...] +---+