Class AnalyzeDepMgt
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.dependency.analyze.AnalyzeDepMgt
- All Implemented Interfaces:
- org.apache.maven.plugin.ContextEnabled,- org.apache.maven.plugin.Mojo
@Mojo(name="analyze-dep-mgt",
      requiresDependencyResolution=TEST,
      threadSafe=true)
public class AnalyzeDepMgt
extends org.apache.maven.plugin.AbstractMojo
This mojo looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement
 section. This mojo is also useful for detecting projects that override the dependencyManagement directly.
 Set ignoreDirect to false to detect these otherwise normal conditions.
- Since:
- 2.0-alpha-3
- Author:
- Brian Fox
- 
Field SummaryFields inherited from interface org.apache.maven.plugin.MojoROLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddExclusions(List<org.apache.maven.model.Exclusion> exclusionList) Returns a map of the exclusions using the Dependency ManagementKey as the keyset.voidexecute()getArtifactManagementKey(org.apache.maven.artifact.Artifact artifact) This function returns a string comparable with Dependency.GetManagementKey.List<org.apache.maven.artifact.Artifact> getExclusionErrors(Map<String, org.apache.maven.model.Exclusion> exclusions, 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.getExclusionKey(org.apache.maven.artifact.Artifact artifact) getExclusionKey(org.apache.maven.model.Exclusion ex) Map<org.apache.maven.artifact.Artifact, org.apache.maven.model.Dependency> getMismatch(Map<String, org.apache.maven.model.Dependency> depMgtMap, Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts) Calculate the mismatches between the DependencyManagement and resolved artifacts.protected final org.apache.maven.project.MavenProjectprotected final booleanprotected final booleanvoidlogMismatch(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.voidsetFailBuild(boolean theFailBuild) voidsetIgnoreDirect(boolean theIgnoreDirect) Methods inherited from class org.apache.maven.plugin.AbstractMojogetLog, getPluginContext, setLog, setPluginContext
- 
Constructor Details- 
AnalyzeDepMgt@Inject public AnalyzeDepMgt(org.apache.maven.project.MavenProject project) 
 
- 
- 
Method Details- 
executepublic void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
- org.apache.maven.plugin.MojoExecutionException
- org.apache.maven.plugin.MojoFailureException
 
- 
addExclusionspublic Map<String,org.apache.maven.model.Exclusion> addExclusions(List<org.apache.maven.model.Exclusion> exclusionList) Returns a map of the exclusions using the Dependency ManagementKey as the keyset.- Parameters:
- exclusionList- to be added to the map
- Returns:
- a map of the exclusions using the Dependency ManagementKey as the keyset
 
- 
getExclusionErrorspublic List<org.apache.maven.artifact.Artifact> getExclusionErrors(Map<String, org.apache.maven.model.Exclusion> exclusions, 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.- Parameters:
- exclusions- a map of the DependencyManagement exclusions, with the ManagementKey as the key and Dependency as the value
- allDependencyArtifacts- resolved artifacts to be compared
- Returns:
- list of artifacts that should have been excluded
 
- 
getExclusionKey- Parameters:
- artifact-- Artifact
- Returns:
- the resulting GA
 
- 
getExclusionKey- Parameters:
- ex- the exclusion key
- Returns:
- the resulting combination of groupId+artifactId
 
- 
getMismatchpublic Map<org.apache.maven.artifact.Artifact,org.apache.maven.model.Dependency> getMismatch(Map<String, org.apache.maven.model.Dependency> depMgtMap, Set<org.apache.maven.artifact.Artifact> allDependencyArtifacts) Calculate the mismatches between the DependencyManagement and resolved artifacts.- Parameters:
- depMgtMap- a keyset of the Dependency.GetManagementKey for quick lookup
- allDependencyArtifacts- the set of all artifacts to compare
- Returns:
- a map containing the resolved artifact as the key and the listed dependency as the value
 
- 
logMismatchpublic void logMismatch(org.apache.maven.artifact.Artifact dependencyArtifact, org.apache.maven.model.Dependency dependencyFromDepMgt) throws org.apache.maven.plugin.MojoExecutionException This function displays the log to the screen showing the versions and information about the artifacts that don't match.- Parameters:
- dependencyArtifact- the artifact that was resolved
- dependencyFromDepMgt- the dependency listed in the DependencyManagement section
- Throws:
- org.apache.maven.plugin.MojoExecutionException- in case of errors
 
- 
getArtifactManagementKeyThis function returns a string comparable with Dependency.GetManagementKey.- Parameters:
- artifact- to gen the key for
- Returns:
- a string in the form: groupId:ArtifactId:Type[:Classifier]
 
- 
isFailBuildprotected final boolean isFailBuild()- Returns:
- the failBuild
 
- 
setFailBuildpublic void setFailBuild(boolean theFailBuild) - Parameters:
- theFailBuild- the failBuild to set
 
- 
getProjectprotected final org.apache.maven.project.MavenProject getProject()- Returns:
- the project
 
- 
isIgnoreDirectprotected final boolean isIgnoreDirect()- Returns:
- the ignoreDirect
 
- 
setIgnoreDirectpublic void setIgnoreDirect(boolean theIgnoreDirect) - Parameters:
- theIgnoreDirect- the ignoreDirect to set
 
 
-