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 org.apache.maven.artifact.handler.manager.ArtifactHandlerManager
private List<ArtifactItem>
Collection of ArtifactItems to work on.private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver
private File
Path to override default local repository during plugin's execution.private File
Default output location used for mojo, unless overridden in ArtifactItem.private boolean
Overwrite if newerprivate boolean
Overwrite release artifactsprivate boolean
Overwrite snapshot artifactsprivate org.apache.maven.shared.transfer.repository.RepositoryManager
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
outputAbsoluteArtifactFilename, reactorProjects, session
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private void
fillMissingArtifactVersion
(ArtifactItem artifact) Tries to find missing version from dependency list and dependency management.private boolean
findDependencyVersion
(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.Artifact
getArtifact
(ArtifactItem artifactItem) Resolves the Artifact from the remote repository if necessary.(package private) abstract ArtifactItemFilter
protected List<ArtifactItem>
getProcessedArtifactItems
(ProcessArtifactItemsRequest processArtifactItemsRequest) Preprocesses the list of ArtifactItems.boolean
boolean
boolean
void
setArtifact
(String artifact) void
setArtifactItems
(List<ArtifactItem> theArtifactItems) void
setLocalRepositoryDirectory
(File localRepositoryDirectory) void
setOutputDirectory
(File theOutputDirectory) void
setOverWriteIfNewer
(boolean theOverWriteIfNewer) void
setOverWriteReleases
(boolean theOverWriteReleases) void
setOverWriteSnapshots
(boolean theOverWriteSnapshots) protected void
artifactItems is filled by either field injection or by setArtifact().Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
copyFile, doExecute, execute, getArchiverManager, getProject, isSilent, isSkip, isUseJvmChmod, newResolveArtifactProjectBuildingRequest, newResolvePluginProjectBuildingRequest, setArchiverManager, setSilent, setSkip, setUseJvmChmod, unpack, unpack, unpack
Methods 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
-
overWriteIfNewer
@Parameter(property="mdep.overIfNewer", defaultValue="true") private boolean overWriteIfNewerOverwrite if newer- Since:
- 2.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
-
artifactResolver
@Component private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver artifactResolver -
repositoryManager
@Component private org.apache.maven.shared.transfer.repository.RepositoryManager repositoryManager -
artifactHandlerManager
@Component private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
-
-
Constructor Details
-
AbstractFromConfigurationMojo
public AbstractFromConfigurationMojo()
-
-
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.plugin.MojoExecutionException, org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException - Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException
-
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
- with a message 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 file.dependencies
- list of dependencies to search.looseMatch
- 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.
-