Class CopyDependenciesMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.AbstractFromDependenciesMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.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 AbstractFromDependenciesMojoGoal 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
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanaddParentPomsAdd parent poms to the list of copied dependencies (both current project pom parents and dependencies parents).protected booleancopyPomAlso copy the pom of each artifact.protected booleancopySignaturesAlso copy the signature files (.asc) of each artifact.private CopyUtilcopyUtilprivate org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerinstallerprivate org.apache.maven.shared.transfer.repository.RepositoryManagerrepositoryManagerprivate static java.lang.StringSIGNATURE_EXTENSIONprotected booleanuseBaseVersionEither append the artifact's baseVersion or uniqueVersion to the filename.-
Fields inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractFromDependenciesMojo
failOnMissingClassifierArtifact, outputDirectory, stripClassifier, stripType, stripVersion, useRepositoryLayout, useSubDirectoryPerArtifact, useSubDirectoryPerScope, useSubDirectoryPerType
-
Fields inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
classifier, excludeArtifactIds, excludeClassifiers, excludeGroupIds, excludeScope, excludeTransitive, excludeTypes, includeArtifactIds, includeClassifiers, includeGroupIds, includeScope, includeTypes, markersDirectory, overWriteIfNewer, overWriteReleases, overWriteSnapshots, prependGroupId, type
-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
session
-
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcopyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion)Copies the Artifact after building the destination file name if overridden.protected voidcopyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion, boolean removeClassifier)Copies the Artifact after building the destination file name if overridden.voidcopyPoms(java.io.File destDir, java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion)Copy the pom files associated with the artifacts.voidcopyPoms(java.io.File destDir, java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion, boolean removeClassifier)Copy the pom files associated with the artifacts.private voidcopySignatureFile(org.apache.maven.artifact.Artifact artifact, java.io.File destDir, java.lang.String destFileName)Copies the signature file of the artifact to the destination directory, if it exists or can be resolved.protected voiddoExecute()Main entry into mojo.protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFiltergetMarkedArtifactFilter()Return anArtifactsFilterindicating which artifacts must be filtered out.protected org.apache.maven.artifact.ArtifactgetResolvedPomArtifact(org.apache.maven.artifact.Artifact artifact)private voidinstallArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest)Install the artifact and the corresponding pom if copyPoms=true.private voidinstallBaseSnapshot(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest)booleanisCopyPom()voidsetCopyPom(boolean copyPom)-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractFromDependenciesMojo
getOutputDirectory, isFailOnMissingClassifierArtifact, isStripType, isStripVersion, isUseRepositoryLayout, isUseSubDirectoryPerArtifact, isUseSubDirectoryPerScope, isUseSubDirectoryPerType, setFailOnMissingClassifierArtifact, setOutputDirectory, setStripType, setStripVersion, setUseRepositoryLayout, setUseSubDirectoryPerArtifact, setUseSubDirectoryPerScope, setUseSubDirectoryPerType
-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
filterMarkedDependencies, getDependencySets, getDependencySets, getMarkersDirectory, getResolvedDependencies, getResolverUtil, isPrependGroupId, setMarkersDirectory, setPrependGroupId
-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
execute, getProject, isSilent, isSkip, setSilent, setSkip
-
-
-
-
Field Detail
-
copyPom
@Parameter(property="mdep.copyPom", defaultValue="false") protected boolean copyPomAlso copy the pom of each artifact.- Since:
- 2.0
-
copyUtil
private final CopyUtil copyUtil
-
installer
private final org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller installer
-
repositoryManager
private final org.apache.maven.shared.transfer.repository.RepositoryManager repositoryManager
-
useBaseVersion
@Parameter(property="mdep.useBaseVersion", defaultValue="true") protected boolean useBaseVersionEither append the artifact's baseVersion or uniqueVersion to the filename. Will only be used ifAbstractFromDependenciesMojo.isStripVersion()isfalse.- Since:
- 2.6
-
addParentPoms
@Parameter(property="mdep.addParentPoms", defaultValue="false") protected boolean addParentPomsAdd 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 copySignaturesAlso copy the signature files (.asc) of each artifact.- Since:
- 3.2.0
-
SIGNATURE_EXTENSION
private static final java.lang.String SIGNATURE_EXTENSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
doExecute
protected void doExecute() throws org.apache.maven.plugin.MojoExecutionExceptionMain entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact.- Specified by:
doExecutein classAbstractDependencyMojo- Throws:
org.apache.maven.plugin.MojoExecutionException- with a message if an error occurs- See Also:
AbstractDependencyFilterMojo.getDependencySets(boolean, boolean),copyArtifact(Artifact, boolean, boolean, boolean, boolean)
-
installArtifact
private void installArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest)Install the artifact and the corresponding pom if copyPoms=true.
-
installBaseSnapshot
private void installBaseSnapshot(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest) throws org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException- Throws:
org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException
-
copyArtifact
protected void copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion) throws org.apache.maven.plugin.MojoExecutionExceptionCopies 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 copiedremoveVersion- specifies if the version should be removed from the file name when copyingprependGroupId- specifies if the group ID should be prefixed to the file while copyingtheUseBaseVersion- 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(Artifact, boolean, boolean, boolean, boolean)
-
copyArtifact
protected void copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion, boolean removeClassifier) throws org.apache.maven.plugin.MojoExecutionExceptionCopies 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 copiedremoveVersion- specifies if the version should be removed from the file name when copyingprependGroupId- specifies if the groupId should be prefixed to the file while copyinguseBaseVersion- specifies if the baseVersion of the artifact should be used instead of the versionremoveClassifier- specifies if the classifier should be removed from the file name when copying- Throws:
org.apache.maven.plugin.MojoExecutionException- with a message if an error occurs- See Also:
CopyUtil.copyArtifactFile(Artifact, File),DependencyUtil.getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact)
-
copySignatureFile
private void copySignatureFile(org.apache.maven.artifact.Artifact artifact, java.io.File destDir, java.lang.String destFileName)Copies the signature file of the artifact to the destination directory, if it exists or can be resolved. If the signature file does not exist and cannot be resolved, a warning is logged.- Parameters:
artifact- the artifact whose signature file should be copieddestDir- the destination directorydestFileName- the destination file name without the extension
-
copyPoms
public void copyPoms(java.io.File destDir, java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion) throws org.apache.maven.plugin.MojoExecutionExceptionCopy the pom files associated with the artifacts.- Parameters:
destDir- the destination directoryFileartifacts- the artifactsArtifactremoveVersion- remove version or not- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of errors
-
copyPoms
public void copyPoms(java.io.File destDir, java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion, boolean removeClassifier) throws org.apache.maven.plugin.MojoExecutionExceptionCopy the pom files associated with the artifacts.- Parameters:
destDir- the destination directoryFileartifacts- the artifactsArtifactremoveVersion- remove version or notremoveClassifier- 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:AbstractDependencyFilterMojoReturn anArtifactsFilterindicating which artifacts must be filtered out.- Specified by:
getMarkedArtifactFilterin classAbstractDependencyFilterMojo- Returns:
- an
ArtifactsFilterindicating 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
-
-