org.apache.maven.plugin.dependency
Class AnalyzeDepMgt

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.maven.plugin.dependency.AnalyzeDepMgt
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

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. In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See MNG-1577 for more info. This mojo is also useful for just detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions.

Since:
2.0-alpha-3
Version:
$Id: AnalyzeDepMgt.java 1085777 2011-03-26 18:13:19Z hboutemy $
Author:
Brian Fox
Is defined by the goal name:
analyze-dep-mgt
Requires the dependencies in this specified scope:
test

Field Summary
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AnalyzeDepMgt()
           
 
Method Summary
 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.
 void execute()
           
 String 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.
 String getExclusionKey(org.apache.maven.artifact.Artifact artifact)
           
 String 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
 org.apache.maven.project.MavenProject getProject()
           
 boolean isFailBuild()
           
 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)
           
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnalyzeDepMgt

public AnalyzeDepMgt()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

addExclusions

public 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.

getExclusionErrors

public 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

public String getExclusionKey(org.apache.maven.artifact.Artifact artifact)

getExclusionKey

public String getExclusionKey(org.apache.maven.model.Exclusion ex)

getMismatch

public 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 - contains the Dependency.GetManagementKey as the keyset for quick lookup.
allDependencyArtifacts - contains the set of all artifacts to compare.
Returns:
a map containing the resolved artifact as the key and the listed dependency as the value.

logMismatch

public 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

getArtifactManagementKey

public String getArtifactManagementKey(org.apache.maven.artifact.Artifact artifact)
This 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]

isFailBuild

public boolean isFailBuild()
Returns:
the failBuild

setFailBuild

public void setFailBuild(boolean theFailBuild)
Parameters:
theFailBuild - the failBuild to set

getProject

public org.apache.maven.project.MavenProject getProject()
Returns:
the project

setProject

public void setProject(org.apache.maven.project.MavenProject theProject)
Parameters:
theProject - the project to set

isIgnoreDirect

public boolean isIgnoreDirect()
Returns:
the ignoreDirect

setIgnoreDirect

public void setIgnoreDirect(boolean theIgnoreDirect)
Parameters:
theIgnoreDirect - the ignoreDirect to set


Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.