Class CopyDependenciesMojo

All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="copy-dependencies", requiresDependencyResolution=TEST, defaultPhase=PROCESS_SOURCES, threadSafe=true) public class CopyDependenciesMojo extends AbstractFromDependenciesMojo
Goal that copies the files for a project's dependencies from the repository to a directory. The default location to copy to is target/dependencies. Since all files are copied to the same directory by default, a dependency that has the same file name as another dependency will be overwritten.
Since:
1.0
Author:
Brian Fox
  • Field Details

    • copyPom

      @Parameter(property="mdep.copyPom", defaultValue="false") protected boolean copyPom
      Also copy the pom of each artifact.
      Since:
      2.0
    • useBaseVersion

      @Parameter(property="mdep.useBaseVersion", defaultValue="true") protected boolean useBaseVersion
      Either append the artifact's baseVersion or uniqueVersion to the filename. Will only be used if AbstractFromDependenciesMojo.isStripVersion() is false.
      Since:
      2.6
    • addParentPoms

      @Parameter(property="mdep.addParentPoms", defaultValue="false") protected boolean addParentPoms
      Add parent poms to the list of copied dependencies (both current project pom parents and dependencies parents).
      Since:
      2.8
    • copySignatures

      @Parameter(property="mdep.copySignatures", defaultValue="false") protected boolean copySignatures
      Also copy the signature files (.asc) of each artifact.
      Since:
      3.2.0
  • Constructor Details

    • CopyDependenciesMojo

      @Inject public CopyDependenciesMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, ResolverUtil resolverUtil, org.apache.maven.shared.transfer.repository.RepositoryManager repositoryManager, org.apache.maven.project.ProjectBuilder projectBuilder, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, CopyUtil copyUtil, org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller installer)
  • Method Details

    • doExecute

      protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException
      Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact.
      Specified by:
      doExecute in class AbstractDependencyMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - with a message if an error occurs
      See Also:
    • copyArtifact

      protected void copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion) throws org.apache.maven.plugin.MojoExecutionException
      Copies the Artifact after building the destination file name if overridden. This method also checks if the classifier is set and adds it to the destination file name if needed.
      Parameters:
      artifact - the object to be copied
      removeVersion - specifies if the version should be removed from the file name when copying
      prependGroupId - specifies if the group ID should be prefixed to the file while copying
      theUseBaseVersion - specifies if the baseVersion of the artifact should be used instead of the version
      Throws:
      org.apache.maven.plugin.MojoExecutionException - with a message if an error occurs
      See Also:
    • copyArtifact

      protected void copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion, boolean removeClassifier) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • copyPoms

      public void copyPoms(File destDir, Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion) throws org.apache.maven.plugin.MojoExecutionException
      Copy the pom files associated with the artifacts.
      Parameters:
      destDir - the destination directory File
      artifacts - the artifacts Artifact
      removeVersion - remove version or not
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of errors
    • copyPoms

      public void copyPoms(File destDir, Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion, boolean removeClassifier) throws org.apache.maven.plugin.MojoExecutionException
      Copy the pom files associated with the artifacts.
      Parameters:
      destDir - the destination directory File
      artifacts - the artifacts Artifact
      removeVersion - remove version or not
      removeClassifier - remove the classifier or not
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of errors
    • getResolvedPomArtifact

      protected org.apache.maven.artifact.Artifact getResolvedPomArtifact(org.apache.maven.artifact.Artifact artifact)
      Parameters:
      artifact - Artifact
      Returns:
      Artifact
    • getMarkedArtifactFilter

      protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter getMarkedArtifactFilter()
      Description copied from class: AbstractDependencyFilterMojo
      Return an ArtifactsFilter indicating which artifacts must be filtered out.
      Specified by:
      getMarkedArtifactFilter in class AbstractDependencyFilterMojo
      Returns:
      an ArtifactsFilter indicating which artifacts must be filtered out
    • isCopyPom

      public boolean isCopyPom()
      Returns:
      true, if the pom of each artifact must be copied
    • setCopyPom

      public void setCopyPom(boolean copyPom)
      Parameters:
      copyPom - true if the pom of each artifact must be copied