java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.basepom.mojo.dvc.AbstractDependencyVersionsMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,Context
- Direct Known Subclasses:
DependencyVersionsCheckMojo
,DependencyVersionsListMojo
public abstract class AbstractDependencyVersionsMojo
extends org.apache.maven.plugin.AbstractMojo
implements Context
Base code for all the mojos. Contains the dependency resolvers and the common options.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Use deep scan or regular scan.Sets the default strategy to use to evaluate whether two dependency versions are compatible or not.boolean
List only direct dependencies or all dependencies.List of version checks that will be removed from the version check.boolean
Run dependency resolution in parallel with multiple threads.boolean
Include POM projects when running on a multi-module project.protected final PluginLog
boolean
List only managed dependencies or all dependencies.org.apache.maven.project.ProjectBuilder
org.apache.maven.execution.MavenSession
protected boolean
Require all optional dependencies to exist and fail the build if any optional dependency can not resolved.org.apache.maven.project.MavenProject
org.apache.maven.project.ProjectDependenciesResolver
boolean
Silence all non-output and non-error messages.List<org.apache.maven.project.MavenProject>
org.eclipse.aether.RepositorySystem
List of resolvers to apply specific strategies to dependencies.Dependency resolution scope.boolean
Skip the plugin execution.protected StrategyCache
The strategy provider.protected boolean
Fail the build if an artifact insystem
scope can not be resolved.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.maven.project.ProjectBuildingRequest
protected ScopeLimitingFilter
Defines the scope used to resolve the project dependencies.org.eclipse.aether.resolution.VersionRangeRequest
createVersionRangeRequest
(org.eclipse.aether.artifact.Artifact artifact) protected abstract void
doExecute
(com.google.common.collect.ImmutableSetMultimap<QualifiedName, VersionResolutionCollection> resolutionMap, DependencyMap rootDependencyMap) Subclasses need to implement this method.void
execute()
org.apache.maven.project.ProjectBuilder
org.apache.maven.project.ProjectDependenciesResolver
List<org.apache.maven.project.MavenProject>
org.eclipse.aether.RepositorySystem
org.eclipse.aether.RepositorySystemSession
org.apache.maven.project.MavenProject
boolean
boolean
boolean
boolean
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
LOG
-
project
@Parameter(defaultValue="${project}", readonly=true) public org.apache.maven.project.MavenProject project -
mavenSession
@Parameter(defaultValue="${session}", readonly=true) public org.apache.maven.execution.MavenSession mavenSession -
reactorProjects
@Parameter(defaultValue="${reactorProjects}", readonly=true, required=true) public List<org.apache.maven.project.MavenProject> reactorProjects -
mavenProjectBuilder
@Component public org.apache.maven.project.ProjectBuilder mavenProjectBuilder -
projectDependenciesResolver
@Component public org.apache.maven.project.ProjectDependenciesResolver projectDependenciesResolver -
repositorySystem
@Component public org.eclipse.aether.RepositorySystem repositorySystem -
strategyProvider
The strategy provider. This can be requested by other pieces to add additional strategies. -
exclusions
List of version checks that will be removed from the version check. This allows potential conflicts to be excluded.
<exclusions> <exclusion> <dependency>...</dependency> <expected>...</expected> <resolved>...</resolved> </exclusion> </exclusions>
Each element consists of a dependency pattern
[groupId]:[artifactId]
that supports wildcards and an expected version (which is the version is expected by the artifact) and a resolved version (the version that the dependency resolution has chosen). -
skip
@Parameter(defaultValue="false", property="dvc.skip") public boolean skipSkip the plugin execution. -
includePomProjects
@Parameter(defaultValue="false", property="dvc.include-pom-projects") public boolean includePomProjectsInclude POM projects when running on a multi-module project. Dependency resolution on a pom project almost never makes sense as it does not actually build any artifacts.- Since:
- 3.0.0
-
quiet
@Parameter(defaultValue="false", property="dvc.quiet") public boolean quietSilence all non-output and non-error messages.- Since:
- 3.0.0
-
scope
Dependency resolution scope. Defaults totest
. Valid choices arecompile+runtime
,compile
,test
andruntime
.- Since:
- 3.0.0
-
deepScan
@Parameter(defaultValue="false", property="dvc.deep-scan") public boolean deepScanUse deep scan or regular scan. Deep scan looks at all dependencies in the dependency tree, while regular scan only looks one level deep into the direct dependencies.- Since:
- 3.0.0
-
directOnly
@Parameter(defaultValue="false", property="dvc.direct-only") public boolean directOnlyList only direct dependencies or all dependencies.- Since:
- 3.0.0
-
managedOnly
@Parameter(defaultValue="false", property="dvc.managed-only") public boolean managedOnlyList only managed dependencies or all dependencies.- Since:
- 3.0.0
-
fastResolution
@Parameter(defaultValue="true", property="dvc.fast-resolution") public boolean fastResolutionRun dependency resolution in parallel with multiple threads. Should only ever set tofalse
if the plugin shows stability problems when resolving dependencies. Please file a bug in that case, too.- Since:
- 3.0.0
-
unresolvedSystemArtifactsFailBuild
@Parameter(defaultValue="false", property="dvc.unresolved-system-artifacts-fail-build") protected boolean unresolvedSystemArtifactsFailBuildFail the build if an artifact insystem
scope can not be resolved. Those are notoriously dependent on the local build environment and some outright fail (e.g. referencing thetools.jar
, which no longer exists in a JDK8+ environment).
Setting this flag totrue
will fail the build if anysystem
scoped artifact can not be resolved. This is almost never desired, except when building a project with a directsystem
scoped dependency.- Since:
- 3.0.0
-
optionalDependenciesMustExist
@Parameter(defaultValue="false", property="dvc.optional-dependencies-must-exist") protected boolean optionalDependenciesMustExistRequire all optional dependencies to exist and fail the build if any optional dependency can not resolved. This is almost never needed and actually causes problems for some projects that use large public dependencies from central that in turn pull in non-public dependencies as optional.- Since:
- 3.2.0
-
resolvers
List of resolvers to apply specific strategies to dependencies.<resolvers> <resolver> <strategy>...<strategy> <includes> <include>...<include> <includes> <resolver> <resolvers>
A resolver maps a specific strategy to a list of includes. The include syntax is[group-id]:[artifact-id]
where each pattern segment supports full and partial wildcards (*
).
The plugin includes some default strategies:apr
,default
,single-digit
andtwo-digits-backward-compatible
. Additional strategies can be defined and added to the plugin classpath. -
defaultStrategy
Sets the default strategy to use to evaluate whether two dependency versions are compatible or not. Thedefault
resolution strategy matches the Maven dependency resolution itself; any two dependencies that maven considers compatible will be accepted.- Since:
- 3.0.0
-
strategyCache
-
-
Constructor Details
-
AbstractDependencyVersionsMojo
public AbstractDependencyVersionsMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
execute
in interfaceorg.apache.maven.plugin.Mojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
doExecute
protected abstract void doExecute(com.google.common.collect.ImmutableSetMultimap<QualifiedName, VersionResolutionCollection> resolutionMap, DependencyMap rootDependencyMap) throws ExceptionSubclasses need to implement this method.- Parameters:
resolutionMap
- The prebuilt resolution map from qualified names to version resolution collections.rootDependencyMap
- The prebuilt dependency map for all the root dependencies.- Throws:
Exception
- When an execution error occurs.
-
createScopeFilter
Defines the scope used to resolve the project dependencies. The project dependencies will be limited to the dependencies that match this filter. The list mojo overrides this to limit the scope in which dependencies are listed. By default, include everything.- Returns:
- The
ScopeLimitingFilter
instance for the project dependencies.
-
useFastResolution
public boolean useFastResolution()- Specified by:
useFastResolution
in interfaceContext
- Returns:
- True if the resolver should use multiple threads.
-
useDeepScan
public boolean useDeepScan()- Specified by:
useDeepScan
in interfaceContext
- Returns:
- True if a deep scan should be performed instead of regular scan.
-
isOptionalDependenciesMustExist
public boolean isOptionalDependenciesMustExist()- Specified by:
isOptionalDependenciesMustExist
in interfaceContext
- Returns:
- True if all optional dependencies must exist.
-
getStrategyCache
- Specified by:
getStrategyCache
in interfaceContext
- Returns:
- The lookup cache for the Strategy resolution
-
getProjectBuilder
public org.apache.maven.project.ProjectBuilder getProjectBuilder()- Specified by:
getProjectBuilder
in interfaceContext
- Returns:
- The Maven project builder.
-
getProjectDependenciesResolver
public org.apache.maven.project.ProjectDependenciesResolver getProjectDependenciesResolver()- Specified by:
getProjectDependenciesResolver
in interfaceContext
- Returns:
- The Maven project dependency resolver.
-
getRootProject
public org.apache.maven.project.MavenProject getRootProject()- Specified by:
getRootProject
in interfaceContext
- Returns:
- The root project.
-
getReactorProjects
- Specified by:
getReactorProjects
in interfaceContext
- Returns:
- All projects that are in the current reactor.
-
getRepositorySystemSession
public org.eclipse.aether.RepositorySystemSession getRepositorySystemSession()- Specified by:
getRepositorySystemSession
in interfaceContext
- Returns:
- The repository session
-
getRepositorySystem
public org.eclipse.aether.RepositorySystem getRepositorySystem()- Specified by:
getRepositorySystem
in interfaceContext
- Returns:
- The repository system for dependency resolution.
-
createProjectBuildingRequest
public org.apache.maven.project.ProjectBuildingRequest createProjectBuildingRequest()- Specified by:
createProjectBuildingRequest
in interfaceContext
- Returns:
- A new project building request.
-
createVersionRangeRequest
public org.eclipse.aether.resolution.VersionRangeRequest createVersionRangeRequest(org.eclipse.aether.artifact.Artifact artifact) - Specified by:
createVersionRangeRequest
in interfaceContext
- Parameters:
artifact
- The artifact to define the version range resolution request.- Returns:
- A version range resolution request.
-
getExclusions
- Specified by:
getExclusions
in interfaceContext
- Returns:
- All configured exclusions.
-
isUnresolvedSystemArtifactsFailBuild
public boolean isUnresolvedSystemArtifactsFailBuild()- Specified by:
isUnresolvedSystemArtifactsFailBuild
in interfaceContext
- Returns:
- True if any unresolved system artifacts should fail the build.
-