Class AbstractFromConfigurationMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.fromConfiguration.AbstractFromConfigurationMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
CopyMojo,UnpackMojo
public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMojo
Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of ArtifactItems.- See Also:
ArtifactItem
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerartifactHandlerManagerprivate java.util.List<ArtifactItem>artifactItemsCollection of ArtifactItems to work on.private java.io.FilelocalRepositoryDirectoryPath to override default local repository during plugin's execution.private java.io.FileoutputDirectoryDefault output location used for mojo, unless overridden in ArtifactItem.private booleanoverIfNewerDeprecated.use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing nowprivate booleanoverWriteIfNewerOverwrite if newer.private booleanoverWriteReleasesOverwrite release artifacts.private booleanoverWriteSnapshotsOverwrite snapshot artifacts.private org.eclipse.aether.RepositorySystemrepositorySystem-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
session
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFromConfigurationMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private booleancheckIfProcessingNeeded(ArtifactItem item)private org.eclipse.aether.RepositorySystemSessioncreateSystemSessionForLocalRepo()private voidfillMissingArtifactVersion(ArtifactItem artifact)Tries to find missing version from dependency list and dependency management.private booleanfindDependencyVersion(ArtifactItem artifact, java.util.List<org.apache.maven.model.Dependency> dependencies, boolean looseMatch)Tries to find missing version from a list of dependencies.protected org.apache.maven.artifact.ArtifactgetArtifact(ArtifactItem artifactItem)Resolves the Artifact from the remote repository if necessary.java.util.List<ArtifactItem>getArtifactItems()(package private) abstract ArtifactItemFiltergetMarkedArtifactFilter(ArtifactItem item)java.io.FilegetOutputDirectory()protected java.util.List<ArtifactItem>getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest)Preprocesses the list of ArtifactItems.booleanisOverWriteIfNewer()booleanisOverWriteReleases()booleanisOverWriteSnapshots()voidsetArtifact(java.lang.String artifact)voidsetArtifactItems(java.util.List<ArtifactItem> theArtifactItems)voidsetLocalRepositoryDirectory(java.io.File localRepositoryDirectory)voidsetOutputDirectory(java.io.File theOutputDirectory)voidsetOverWriteIfNewer(boolean theOverWriteIfNewer)voidsetOverWriteReleases(boolean theOverWriteReleases)voidsetOverWriteSnapshots(boolean theOverWriteSnapshots)protected voidverifyRequirements()ArtifactItems is filled by either field injection or by setArtifact().-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
doExecute, execute, getProject, isSilent, isSkip, setSilent, setSkip
-
-
-
-
Field Detail
-
outputDirectory
@Parameter(property="outputDirectory", defaultValue="${project.build.directory}/dependency") private java.io.File outputDirectoryDefault output location used for mojo, unless overridden in ArtifactItem.- Since:
- 1.0
-
overWriteReleases
@Parameter(property="mdep.overWriteReleases", defaultValue="false") private boolean overWriteReleasesOverwrite release artifacts.- Since:
- 1.0
-
overWriteSnapshots
@Parameter(property="mdep.overWriteSnapshots", defaultValue="false") private boolean overWriteSnapshotsOverwrite snapshot artifacts.- Since:
- 1.0
-
overIfNewer
@Deprecated @Parameter(property="mdep.overIfNewer", defaultValue="true") private boolean overIfNewerDeprecated.use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing nowOverwrite if newer.- Since:
- 2.0
-
overWriteIfNewer
@Parameter(property="mdep.overWriteIfNewer", defaultValue="true") private boolean overWriteIfNewerOverwrite if newer.- Since:
- 3.7.0
-
artifactItems
@Parameter private java.util.List<ArtifactItem> artifactItems
Collection of ArtifactItems to work on. (ArtifactItem contains groupId, artifactId, version, type, classifier, outputDirectory, destFileName, overWrite and encoding.) See Usage for details.- Since:
- 1.0
-
localRepositoryDirectory
@Parameter private java.io.File localRepositoryDirectory
Path to override default local repository during plugin's execution. To remove all downloaded artifacts as part of the build, set this value to a location under your project's target directory.- Since:
- 2.2
-
artifactHandlerManager
private final org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
-
repositorySystem
private final org.eclipse.aether.RepositorySystem repositorySystem
-
-
Constructor Detail
-
AbstractFromConfigurationMojo
protected AbstractFromConfigurationMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem)
-
-
Method Detail
-
getMarkedArtifactFilter
abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item)
-
verifyRequirements
protected void verifyRequirements() throws org.apache.maven.plugin.MojoFailureExceptionArtifactItems is filled by either field injection or by setArtifact().- Throws:
org.apache.maven.plugin.MojoFailureException- in case of an error
-
getProcessedArtifactItems
protected java.util.List<ArtifactItem> getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) throws org.apache.maven.plugin.MojoExecutionException
Preprocesses the list of ArtifactItems. This method defaults the outputDirectory if not set and creates the output Directory if it doesn't exist.- Parameters:
processArtifactItemsRequest- preprocessing instructions- Returns:
- an ArrayList of preprocessed ArtifactItems
- Throws:
org.apache.maven.plugin.MojoExecutionException- with a message if an error occurs- See Also:
ArtifactItem
-
checkIfProcessingNeeded
private boolean checkIfProcessingNeeded(ArtifactItem item) throws org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException
- Throws:
org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException
-
createSystemSessionForLocalRepo
private org.eclipse.aether.RepositorySystemSession createSystemSessionForLocalRepo()
-
getArtifact
protected org.apache.maven.artifact.Artifact getArtifact(ArtifactItem artifactItem) throws org.apache.maven.plugin.MojoExecutionException
Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved from the dependency list or from the DependencyManagement section of the pom.- Parameters:
artifactItem- containing information about artifact from plugin configuration- Returns:
- artifact object representing the specified file
- Throws:
org.apache.maven.plugin.MojoExecutionException- if the version can't be found in DependencyManagement
-
fillMissingArtifactVersion
private void fillMissingArtifactVersion(ArtifactItem artifact) throws org.apache.maven.plugin.MojoExecutionException
Tries to find missing version from dependency list and dependency management. If found, the artifact is updated with the correct version. It will first look for an exact match on artifactId/groupId/classifier/type and if it doesn't find a match, it will try again looking for artifactId and groupId only.- Parameters:
artifact- representing configured file- Throws:
org.apache.maven.plugin.MojoExecutionException
-
findDependencyVersion
private boolean findDependencyVersion(ArtifactItem artifact, java.util.List<org.apache.maven.model.Dependency> dependencies, boolean looseMatch)
Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct version.- Parameters:
artifact- representing configured filedependencies- list of dependencies to searchlooseMatch- only look at artifactId and groupId- Returns:
- the found dependency
-
getArtifactItems
public java.util.List<ArtifactItem> getArtifactItems()
- Returns:
- returns the artifactItems
-
setArtifactItems
public void setArtifactItems(java.util.List<ArtifactItem> theArtifactItems)
- Parameters:
theArtifactItems- the artifactItems to set
-
getOutputDirectory
public java.io.File getOutputDirectory()
- Returns:
- returns the outputDirectory
-
setOutputDirectory
public void setOutputDirectory(java.io.File theOutputDirectory)
- Parameters:
theOutputDirectory- the outputDirectory to set
-
isOverWriteIfNewer
public boolean isOverWriteIfNewer()
- Returns:
- returns the overWriteIfNewer
-
setOverWriteIfNewer
public void setOverWriteIfNewer(boolean theOverWriteIfNewer)
- Parameters:
theOverWriteIfNewer- the overWriteIfNewer to set
-
isOverWriteReleases
public boolean isOverWriteReleases()
- Returns:
- returns the overWriteReleases
-
setOverWriteReleases
public void setOverWriteReleases(boolean theOverWriteReleases)
- Parameters:
theOverWriteReleases- the overWriteReleases to set
-
isOverWriteSnapshots
public boolean isOverWriteSnapshots()
- Returns:
- returns the overWriteSnapshots
-
setOverWriteSnapshots
public void setOverWriteSnapshots(boolean theOverWriteSnapshots)
- Parameters:
theOverWriteSnapshots- the overWriteSnapshots to set
-
setLocalRepositoryDirectory
public void setLocalRepositoryDirectory(java.io.File localRepositoryDirectory)
- Parameters:
localRepositoryDirectory-localRepositoryDirectory
-
setArtifact
public void setArtifact(java.lang.String artifact) throws org.apache.maven.plugin.MojoFailureException- Parameters:
artifact- the artifact- Throws:
org.apache.maven.plugin.MojoFailureException- in case of an error
-
-