@Mojo(name="analyze-dep-mgt",
requiresDependencyResolution=TEST,
threadSafe=true)
public class AnalyzeDepMgt
extends org.apache.maven.plugin.AbstractMojo
Modifier and Type | Field and Description |
---|---|
private boolean |
failBuild
Fail the build if a problem is detected.
|
private boolean |
ignoreDirect
Ignore Direct Dependency Overrides of dependencyManagement section.
|
private org.apache.maven.project.MavenProject |
project |
private boolean |
skip
Skip plugin execution completely.
|
Constructor and Description |
---|
AnalyzeDepMgt() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,org.apache.maven.model.Exclusion> |
addExclusions(java.util.List<org.apache.maven.model.Exclusion> exclusionList)
Returns a map of the exclusions using the Dependency ManagementKey as the keyset.
|
private boolean |
checkDependencyManagement()
Does the work of checking the DependencyManagement Section.
|
void |
execute() |
java.lang.String |
getArtifactManagementKey(org.apache.maven.artifact.Artifact artifact)
This function returns a string comparable with Dependency.GetManagementKey.
|
java.util.List<org.apache.maven.artifact.Artifact> |
getExclusionErrors(java.util.Map<java.lang.String,org.apache.maven.model.Exclusion> exclusions,
java.util.Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts)
Returns a List of the artifacts that should have been excluded, but were found in the dependency tree.
|
java.lang.String |
getExclusionKey(org.apache.maven.artifact.Artifact artifact) |
java.lang.String |
getExclusionKey(org.apache.maven.model.Exclusion ex) |
java.util.Map<org.apache.maven.artifact.Artifact,org.apache.maven.model.Dependency> |
getMismatch(java.util.Map<java.lang.String,org.apache.maven.model.Dependency> depMgtMap,
java.util.Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts)
Calculate the mismatches between the DependencyManagement and resolved artifacts
|
protected org.apache.maven.project.MavenProject |
getProject() |
protected boolean |
isFailBuild() |
protected boolean |
isIgnoreDirect() |
void |
logMismatch(org.apache.maven.artifact.Artifact dependencyArtifact,
org.apache.maven.model.Dependency dependencyFromDepMgt)
This function displays the log to the screen showing the versions and information about the artifacts that don't
match.
|
void |
setFailBuild(boolean theFailBuild) |
void |
setIgnoreDirect(boolean theIgnoreDirect) |
void |
setProject(org.apache.maven.project.MavenProject theProject) |
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
@Parameter(property="mdep.analyze.failBuild", defaultValue="false") private boolean failBuild
@Parameter(property="mdep.analyze.ignore.direct", defaultValue="true") private boolean ignoreDirect
@Parameter(property="mdep.analyze.skip", defaultValue="false") private boolean skip
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
private boolean checkDependencyManagement() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public java.util.Map<java.lang.String,org.apache.maven.model.Exclusion> addExclusions(java.util.List<org.apache.maven.model.Exclusion> exclusionList)
exclusionList
- to be added to the map.public java.util.List<org.apache.maven.artifact.Artifact> getExclusionErrors(java.util.Map<java.lang.String,org.apache.maven.model.Exclusion> exclusions, java.util.Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts)
exclusions
- a map of the DependencyManagement exclusions, with the ManagementKey as the key and Dependency
as the value.allDependencyArtifacts
- resolved artifacts to be compared.public java.lang.String getExclusionKey(org.apache.maven.artifact.Artifact artifact)
public java.lang.String getExclusionKey(org.apache.maven.model.Exclusion ex)
public java.util.Map<org.apache.maven.artifact.Artifact,org.apache.maven.model.Dependency> getMismatch(java.util.Map<java.lang.String,org.apache.maven.model.Dependency> depMgtMap, java.util.Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts)
depMgtMap
- contains the Dependency.GetManagementKey as the keyset for quick lookup.allDependencyArtifacts
- contains the set of all artifacts to compare.public void logMismatch(org.apache.maven.artifact.Artifact dependencyArtifact, org.apache.maven.model.Dependency dependencyFromDepMgt) throws org.apache.maven.plugin.MojoExecutionException
dependencyArtifact
- the artifact that was resolved.dependencyFromDepMgt
- the dependency listed in the DependencyManagement section.org.apache.maven.plugin.MojoExecutionException
- in case of errors.public java.lang.String getArtifactManagementKey(org.apache.maven.artifact.Artifact artifact)
artifact
- to gen the key forprotected final boolean isFailBuild()
public void setFailBuild(boolean theFailBuild)
theFailBuild
- the failBuild to setprotected final org.apache.maven.project.MavenProject getProject()
public void setProject(org.apache.maven.project.MavenProject theProject)
theProject
- the project to setprotected final boolean isIgnoreDirect()
public void setIgnoreDirect(boolean theIgnoreDirect)
theIgnoreDirect
- the ignoreDirect to set