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.ArtifactHandlerManager
artifactHandlerManager
private java.util.List<ArtifactItem>
artifactItems
Collection of ArtifactItems to work on.private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver
artifactResolver
private java.io.File
localRepositoryDirectory
Path to override default local repository during plugin's execution.private java.io.File
outputDirectory
Default output location used for mojo, unless overridden in ArtifactItem.private boolean
overWriteIfNewer
Overwrite if newerprivate boolean
overWriteReleases
Overwrite release artifactsprivate boolean
overWriteSnapshots
Overwrite snapshot artifactsprivate org.apache.maven.shared.transfer.repository.RepositoryManager
repositoryManager
-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
outputAbsoluteArtifactFilename, reactorProjects, session
-
-
Constructor Summary
Constructors Constructor Description AbstractFromConfigurationMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private boolean
checkIfProcessingNeeded(ArtifactItem item)
private void
fillMissingArtifactVersion(ArtifactItem artifact)
Tries to find missing version from dependency list and dependency management.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.protected org.apache.maven.artifact.Artifact
getArtifact(ArtifactItem artifactItem)
Resolves the Artifact from the remote repository if necessary.java.util.List<ArtifactItem>
getArtifactItems()
(package private) abstract ArtifactItemFilter
getMarkedArtifactFilter(ArtifactItem item)
java.io.File
getOutputDirectory()
protected java.util.List<ArtifactItem>
getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest)
Preprocesses the list of ArtifactItems.boolean
isOverWriteIfNewer()
boolean
isOverWriteReleases()
boolean
isOverWriteSnapshots()
void
setArtifact(java.lang.String artifact)
void
setArtifactItems(java.util.List<ArtifactItem> theArtifactItems)
void
setLocalRepositoryDirectory(java.io.File localRepositoryDirectory)
void
setOutputDirectory(java.io.File theOutputDirectory)
void
setOverWriteIfNewer(boolean theOverWriteIfNewer)
void
setOverWriteReleases(boolean theOverWriteReleases)
void
setOverWriteSnapshots(boolean theOverWriteSnapshots)
protected void
verifyRequirements()
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, setArchiverManager, setSilent, setSkip, setUseJvmChmod, unpack, unpack, unpack
-
-
-
-
Field Detail
-
outputDirectory
@Parameter(property="outputDirectory", defaultValue="${project.build.directory}/dependency") private java.io.File outputDirectory
Default output location used for mojo, unless overridden in ArtifactItem.- Since:
- 1.0
-
overWriteReleases
@Parameter(property="mdep.overWriteReleases", defaultValue="false") private boolean overWriteReleases
Overwrite release artifacts- Since:
- 1.0
-
overWriteSnapshots
@Parameter(property="mdep.overWriteSnapshots", defaultValue="false") private boolean overWriteSnapshots
Overwrite snapshot artifacts- Since:
- 1.0
-
overWriteIfNewer
@Parameter(property="mdep.overIfNewer", defaultValue="true") private boolean overWriteIfNewer
Overwrite if newer- Since:
- 2.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
-
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
-
-
Method Detail
-
getMarkedArtifactFilter
abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item)
-
verifyRequirements
protected void verifyRequirements() throws org.apache.maven.plugin.MojoFailureException
artifactItems 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.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, 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 file.dependencies
- list of dependencies to search.looseMatch
- 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.
-
-