Class AbstractDependencyFilterMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractFromDependenciesMojo,AbstractResolveMojo,BuildClasspathMojo,GoOfflineMojo,RenderDependenciesMojo
public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMojo
Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering.- See Also:
AbstractDependencyMojo
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerartifactHandlerManagerprotected java.lang.StringclassifierSpecify classifier to look for.protected java.lang.StringexcludeArtifactIdsComma-separated list of artifact IDs to exclude.protected java.lang.StringexcludeClassifiersComma-separated list of Classifiers to exclude.protected java.lang.StringexcludeGroupIdsComma-separated list of group IDs to exclude.protected java.lang.StringexcludeScopeScope threshold to exclude, if no value is defined for include.protected booleanexcludeTransitiveIf we should exclude transitive dependencies.protected java.lang.StringexcludeTypesComma-separated list of Types to exclude.private java.util.List<GraphRoot>graphRootsBy default, this goal uses the project itself as the root of the dependency tree.protected java.lang.StringincludeArtifactIdsComma-separated list of artifact IDs to include.protected java.lang.StringincludeClassifiersComma-separated list of Classifiers to include.protected java.lang.StringincludeGroupIdsComma-separated list of group IDs to include.protected java.lang.StringincludeScopeScope threshold to include.protected java.lang.StringincludeTypesComma-separated list of Types to include.protected java.io.FilemarkersDirectoryDirectory to store flag files.protected booleanoverWriteIfNewerOverwrite artifacts that don't exist or are older than the source.protected booleanoverWriteReleasesOverwrite release artifacts.protected booleanoverWriteSnapshotsOverwrite snapshot artifacts.protected booleanprependGroupIdPrepend the group ID during copy.private org.apache.maven.project.ProjectBuilderprojectBuilderprivate ResolverUtilresolverUtilprotected java.lang.StringtypeSpecify type to look for when constructing artifact based on classifier.-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
session
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDependencyFilterMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, ResolverUtil resolverUtil, org.apache.maven.project.ProjectBuilder projectBuilder, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidaddParentArtifacts(org.apache.maven.project.MavenProject project, java.util.Set<org.apache.maven.artifact.Artifact> artifacts)private org.apache.maven.project.MavenProjectbuildProjectFromArtifact(org.apache.maven.artifact.Artifact artifact)private java.util.Set<org.apache.maven.artifact.Artifact>collectArtifacts(org.apache.maven.project.MavenProject project)protected DependencyStatusSetsfilterMarkedDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)Filter the marked dependencies.private DependencyStatusSetsgetClassifierTranslatedDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean stopOnFailure)Transform artifacts.protected DependencyStatusSetsgetDependencySets(boolean stopOnFailure)protected DependencyStatusSetsgetDependencySets(boolean stopOnFailure, boolean includeParents)Method creates filters and filters the projects dependencies.protected abstract org.apache.maven.shared.artifact.filter.collection.ArtifactsFiltergetMarkedArtifactFilter()Return anArtifactsFilterindicating which artifacts must be filtered out.java.io.FilegetMarkersDirectory()protected java.util.Set<org.apache.maven.artifact.Artifact>getResolvedDependencies(boolean stopOnFailure)Retrieves dependencies, either direct only or all including transitive.protected ResolverUtilgetResolverUtil()booleanisPrependGroupId()private java.util.Set<org.apache.maven.artifact.Artifact>resolve(java.util.Set<org.eclipse.aether.artifact.Artifact> artifacts, boolean stopOnFailure)private java.util.Set<org.apache.maven.artifact.Artifact>resolveDependencyArtifacts(org.apache.maven.model.Dependency root)voidsetMarkersDirectory(java.io.File theMarkersDirectory)voidsetPrependGroupId(boolean prependGroupId)-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
doExecute, execute, getProject, isSilent, isSkip, setSilent, setSkip
-
-
-
-
Field Detail
-
overWriteReleases
@Parameter(property="overWriteReleases", defaultValue="false") protected boolean overWriteReleasesOverwrite release artifacts.- Since:
- 1.0
-
overWriteSnapshots
@Parameter(property="overWriteSnapshots", defaultValue="false") protected boolean overWriteSnapshotsOverwrite snapshot artifacts.- Since:
- 1.0
-
overWriteIfNewer
@Parameter(property="overWriteIfNewer", defaultValue="true") protected boolean overWriteIfNewerOverwrite artifacts that don't exist or are older than the source.- Since:
- 2.0
-
excludeTransitive
@Parameter(property="excludeTransitive", defaultValue="false") protected boolean excludeTransitiveIf we should exclude transitive dependencies.- Since:
- 2.0
-
includeTypes
@Parameter(property="includeTypes", defaultValue="") protected java.lang.String includeTypesComma-separated list of Types to include. Empty String indicates include everything (default).- Since:
- 2.0
-
excludeTypes
@Parameter(property="excludeTypes", defaultValue="") protected java.lang.String excludeTypesComma-separated list of Types to exclude. Empty String indicates don't exclude anything (default).- Since:
- 2.0
-
includeScope
@Parameter(property="includeScope", defaultValue="") protected java.lang.String includeScopeScope threshold to include. An empty string indicates include all dependencies (default).
The scope threshold value being interpreted is the scope as Maven filters for creating a classpath, not as specified in the pom. In summary:runtimeinclude scope gives runtime and compile dependencies,compileinclude scope gives compile, provided, and system dependencies,testinclude scope gives all dependencies (equivalent to default),providedinclude scope just gives provided dependencies,systeminclude scope just gives system dependencies.
- Since:
- 2.0
-
excludeScope
@Parameter(property="excludeScope", defaultValue="") protected java.lang.String excludeScopeScope threshold to exclude, if no value is defined for include. An empty string indicates no dependencies (default). Unlike the other exclusion parameters, this property does not support a comma-delimited list of scope exclusions. Just one scope may be excluded at a time.
The scope threshold value being interpreted is the scope as Maven filters for creating a classpath, not as specified in the pom. In summary:runtimeexclude scope excludes runtime and compile dependencies,compileexclude scope excludes compile, provided, and system dependencies,testexclude scope excludes all dependencies, then not really a legitimate option: it will fail, you probably meant to configure includeScope = compileprovidedexclude scope just excludes provided dependencies,systemexclude scope just excludes system dependencies.
- Since:
- 2.0
-
includeClassifiers
@Parameter(property="includeClassifiers", defaultValue="") protected java.lang.String includeClassifiersComma-separated list of Classifiers to include. Empty string indicates include everything (default).- Since:
- 2.0
-
excludeClassifiers
@Parameter(property="excludeClassifiers", defaultValue="") protected java.lang.String excludeClassifiersComma-separated list of Classifiers to exclude. Empty String indicates don't exclude anything (default).- Since:
- 2.0
-
classifier
@Parameter(property="classifier", defaultValue="") protected java.lang.String classifierSpecify classifier to look for. Example: sources.- Since:
- 2.0
-
type
@Parameter(property="type", defaultValue="") protected java.lang.String typeSpecify type to look for when constructing artifact based on classifier. Example: java-source,jar,war.- Since:
- 2.0
-
excludeArtifactIds
@Parameter(property="excludeArtifactIds", defaultValue="") protected java.lang.String excludeArtifactIdsComma-separated list of artifact IDs to exclude.- Since:
- 2.0
-
includeArtifactIds
@Parameter(property="includeArtifactIds", defaultValue="") protected java.lang.String includeArtifactIdsComma-separated list of artifact IDs to include. Empty String indicates include everything (default).- Since:
- 2.0
-
excludeGroupIds
@Parameter(property="excludeGroupIds", defaultValue="") protected java.lang.String excludeGroupIdsComma-separated list of group IDs to exclude.- Since:
- 2.0
-
includeGroupIds
@Parameter(property="includeGroupIds", defaultValue="") protected java.lang.String includeGroupIdsComma-separated list of group IDs to include. Empty string indicates include everything (default).- Since:
- 2.0
-
markersDirectory
@Parameter(property="markersDirectory", defaultValue="${project.build.directory}/dependency-maven-plugin-markers") protected java.io.File markersDirectoryDirectory to store flag files.- Since:
- 2.0
-
prependGroupId
@Parameter(property="mdep.prependGroupId", defaultValue="false") protected boolean prependGroupIdPrepend the group ID during copy.- Since:
- 2.2
-
graphRoots
@Parameter private java.util.List<GraphRoot> graphRoots
By default, this goal uses the project itself as the root of the dependency tree. With graphRoots, you can select a subtree of dependencies based on groupId and artifactId. After that, the general include/exclude filters can be applied.- Since:
- 3.10.0
-
resolverUtil
private final ResolverUtil resolverUtil
-
projectBuilder
private final org.apache.maven.project.ProjectBuilder projectBuilder
-
artifactHandlerManager
private final org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
-
-
Constructor Detail
-
AbstractDependencyFilterMojo
@Inject protected AbstractDependencyFilterMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, ResolverUtil resolverUtil, org.apache.maven.project.ProjectBuilder projectBuilder, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager)
-
-
Method Detail
-
getMarkedArtifactFilter
protected abstract org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter getMarkedArtifactFilter()
Return anArtifactsFilterindicating which artifacts must be filtered out.- Returns:
- an
ArtifactsFilterindicating which artifacts must be filtered out
-
getResolvedDependencies
protected java.util.Set<org.apache.maven.artifact.Artifact> getResolvedDependencies(boolean stopOnFailure) throws org.apache.maven.plugin.MojoExecutionExceptionRetrieves dependencies, either direct only or all including transitive.- Parameters:
stopOnFailure- true to fail if resolution does not work or false not to fail- Returns:
- a set of artifacts
- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of errors
-
getDependencySets
protected DependencyStatusSets getDependencySets(boolean stopOnFailure) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
stopOnFailure- true/false- Returns:
DependencyStatusSets- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of an error
-
getDependencySets
protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean includeParents) throws org.apache.maven.plugin.MojoExecutionException
Method creates filters and filters the projects dependencies. This method also transforms the dependencies if classifier is set. The dependencies are filtered in least specific to most specific order.- Parameters:
stopOnFailure- true to fail if artifacts can't be resolved false otherwiseincludeParents-trueif parents should be included or notfalse- Returns:
- DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies
- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of errors
-
buildProjectFromArtifact
private org.apache.maven.project.MavenProject buildProjectFromArtifact(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
addParentArtifacts
private void addParentArtifacts(org.apache.maven.project.MavenProject project, java.util.Set<org.apache.maven.artifact.Artifact> artifacts) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getClassifierTranslatedDependencies
private DependencyStatusSets getClassifierTranslatedDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, boolean stopOnFailure) throws org.apache.maven.plugin.MojoExecutionException
Transform artifacts.- Parameters:
artifacts- set of artifactsArtifactstopOnFailure- true/false- Returns:
- DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies
- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of an error
-
filterMarkedDependencies
protected DependencyStatusSets filterMarkedDependencies(java.util.Set<org.apache.maven.artifact.Artifact> artifacts) throws org.apache.maven.plugin.MojoExecutionException
Filter the marked dependencies.- Parameters:
artifacts- the artifacts setArtifact- Returns:
- status set
DependencyStatusSets - Throws:
org.apache.maven.plugin.MojoExecutionException- in case of an error
-
resolve
private java.util.Set<org.apache.maven.artifact.Artifact> resolve(java.util.Set<org.eclipse.aether.artifact.Artifact> artifacts, boolean stopOnFailure) throws org.apache.maven.plugin.MojoExecutionException- Parameters:
artifacts- the set of artifactsstopOnFailure-trueif we should fail with exception if an artifact couldn't be resolvedfalseotherwise- Returns:
- the resolved artifacts.
Artifact. - Throws:
org.apache.maven.plugin.MojoExecutionException- in case of error
-
collectArtifacts
private java.util.Set<org.apache.maven.artifact.Artifact> collectArtifacts(org.apache.maven.project.MavenProject project) throws org.eclipse.aether.resolution.DependencyResolutionException- Throws:
org.eclipse.aether.resolution.DependencyResolutionException
-
resolveDependencyArtifacts
private java.util.Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts(org.apache.maven.model.Dependency root) throws org.eclipse.aether.resolution.DependencyResolutionException- Throws:
org.eclipse.aether.resolution.DependencyResolutionException
-
getMarkersDirectory
public java.io.File getMarkersDirectory()
- Returns:
- returns the markersDirectory
-
setMarkersDirectory
public void setMarkersDirectory(java.io.File theMarkersDirectory)
- Parameters:
theMarkersDirectory- the markersDirectory to set
-
isPrependGroupId
public boolean isPrependGroupId()
- Returns:
- true, if the groupId should be prepended to the filename
-
setPrependGroupId
public void setPrependGroupId(boolean prependGroupId)
- Parameters:
prependGroupId- true if the groupId must be prepended during the copy
-
getResolverUtil
protected final ResolverUtil getResolverUtil()
- Returns:
resolverUtil
-
-