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 AbstractFromDependenciesMojo
Goal that copies the project dependencies from the repository to a defined location.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
addParentPoms
Add parent poms to the list of copied dependencies (both current project pom parents and dependencies parents).protected boolean
copyPom
Also copy the pom of each artifact.protected boolean
ignorePermissions
not used in this goalprivate org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller
installer
private java.util.Map<java.lang.String,org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout>
repositoryLayouts
protected boolean
useBaseVersion
Either append the artifact's baseVersion or uniqueVersion to the filename.protected boolean
useJvmChmod
not used in this goal-
Fields inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractFromDependenciesMojo
failOnMissingClassifierArtifact, outputDirectory, stripClassifier, 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
outputAbsoluteArtifactFilename, reactorProjects, session
-
-
Constructor Summary
Constructors Constructor Description CopyDependenciesMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion)
Copies the Artifact after building the destination file name if overridden.protected void
copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion, boolean removeClassifier)
Copies the Artifact after building the destination file name if overridden.void
copyPoms(java.io.File destDir, java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean removeVersion)
Copy the pom files associated with the artifacts.void
copyPoms(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.protected void
doExecute()
Main entry into mojo.protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter
getMarkedArtifactFilter()
Return anArtifactsFilter
indicating which artifacts must be filtered out.protected org.apache.maven.artifact.Artifact
getResolvedPomArtifact(org.apache.maven.artifact.Artifact artifact)
private void
installArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest)
install the artifact and the corresponding pom if copyPoms=trueprivate void
installBaseSnapshot(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest)
boolean
isCopyPom()
void
setCopyPom(boolean copyPom)
-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractFromDependenciesMojo
getOutputDirectory, isFailOnMissingClassifierArtifact, isStripVersion, isUseRepositoryLayout, isUseSubDirectoryPerArtifact, isUseSubDirectoryPerScope, isUseSubDirectoryPerType, setFailOnMissingClassifierArtifact, setOutputDirectory, setStripVersion, setUseRepositoryLayout, setUseSubDirectoryPerArtifact, setUseSubDirectoryPerScope, setUseSubDirectoryPerType
-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
filterMarkedDependencies, getArtifactResolver, getClassifierTranslatedDependencies, getDependencyResolver, getDependencySets, getDependencySets, getMarkersDirectory, getRepositoryManager, getResolvedDependencies, isPrependGroupId, resolve, setMarkersDirectory, setPrependGroupId
-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
copyFile, execute, getArchiverManager, getProject, isSilent, isSkip, isUseJvmChmod, newResolveArtifactProjectBuildingRequest, setArchiverManager, setSilent, setSkip, setUseJvmChmod, unpack, unpack, unpack
-
-
-
-
Field Detail
-
copyPom
@Parameter(property="mdep.copyPom", defaultValue="false") protected boolean copyPom
Also copy the pom of each artifact.- Since:
- 2.0
-
installer
@Component private org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller installer
-
repositoryLayouts
@Component(role=org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout.class) private java.util.Map<java.lang.String,org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout> repositoryLayouts
-
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 ifAbstractFromDependenciesMojo.isStripVersion()
isfalse
.- 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
-
useJvmChmod
@Parameter protected boolean useJvmChmod
not used in this goal
-
ignorePermissions
@Parameter protected boolean ignorePermissions
not used in this goal
-
-
Method Detail
-
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 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- Parameters:
artifact
-targetRepository
-
-
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.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
- representing the object to be copied.removeVersion
- specifies if the version should be removed from the file name when copying.prependGroupId
- specifies if the groupId should be prepend 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(Artifact, boolean, boolean, boolean, boolean)
-
copyArtifact
protected void copyArtifact(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean theUseBaseVersion, boolean removeClassifier) 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
- representing the object to be copied.removeVersion
- specifies if the version should be removed from the file name when copying.prependGroupId
- specifies if the groupId should be prepend to the file while copying.theUseBaseVersion
- specifies if the baseVersion of the artifact should be used instead of the version.removeClassifier
- 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:
AbstractDependencyMojo.copyFile(File, File)
,DependencyUtil.getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, File, Artifact)
-
copyPoms
public void copyPoms(java.io.File destDir, java.util.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 directoryFile
.artifacts
- The artifactsArtifact
.removeVersion
- 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.MojoExecutionException
Copy the pom files associated with the artifacts.- Parameters:
destDir
- The destination directoryFile
.artifacts
- The artifactsArtifact
.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 anArtifactsFilter
indicating which artifacts must be filtered out.- Specified by:
getMarkedArtifactFilter
in classAbstractDependencyFilterMojo
- 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
-
-