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
Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of
ArtifactItems.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerprivate List<ArtifactItem> Collection of ArtifactItems to work on.private FilePath to override default local repository during plugin's execution.private FileDefault output location used for mojo, unless overridden in ArtifactItem.private booleanDeprecated.use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing nowprivate booleanOverwrite if newer.private booleanOverwrite release artifacts.private booleanOverwrite snapshot artifacts.private final org.eclipse.aether.RepositorySystemFields inherited from class AbstractDependencyMojo
sessionFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFromConfigurationMojo(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
Modifier and TypeMethodDescriptionprivate booleanprivate org.eclipse.aether.RepositorySystemSessionprivate voidfillMissingArtifactVersion(ArtifactItem artifact) Tries to find missing version from dependency list and dependency management.private booleanfindDependencyVersion(ArtifactItem artifact, 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.(package private) abstract ArtifactItemFilterprotected List<ArtifactItem> getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) Preprocesses the list of ArtifactItems.booleanbooleanbooleanvoidsetArtifact(String artifact) voidsetArtifactItems(List<ArtifactItem> theArtifactItems) voidsetLocalRepositoryDirectory(File localRepositoryDirectory) voidsetOutputDirectory(File theOutputDirectory) voidsetOverWriteIfNewer(boolean theOverWriteIfNewer) voidsetOverWriteReleases(boolean theOverWriteReleases) voidsetOverWriteSnapshots(boolean theOverWriteSnapshots) protected voidArtifactItems is filled by either field injection or by setArtifact().Methods inherited from class AbstractDependencyMojo
doExecute, execute, getProject, isSilent, isSkip, setSilent, setSkipMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
outputDirectory
@Parameter(property="outputDirectory", defaultValue="${project.build.directory}/dependency") private 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
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
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 Details
-
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 Details
-
getMarkedArtifactFilter
-
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 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:
-
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, 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
- Returns:
- returns the artifactItems
-
setArtifactItems
- Parameters:
theArtifactItems- the artifactItems to set
-
getOutputDirectory
- Returns:
- returns the outputDirectory
-
setOutputDirectory
- 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
- Parameters:
localRepositoryDirectory-localRepositoryDirectory
-
setArtifact
- Parameters:
artifact- the artifact- Throws:
org.apache.maven.plugin.MojoFailureException- in case of an error
-