Class DependencyConvergence

java.lang.Object
org.apache.maven.plugins.enforcer.DependencyConvergence
All Implemented Interfaces:
EnforcerRule

public class DependencyConvergence extends Object implements EnforcerRule
  • Field Details

    • log

      private static org.apache.maven.plugin.logging.Log log
    • uniqueVersions

      private boolean uniqueVersions
  • Constructor Details

    • DependencyConvergence

      public DependencyConvergence()
  • Method Details

    • setUniqueVersions

      public void setUniqueVersions(boolean uniqueVersions)
    • getNode

      private org.apache.maven.shared.dependency.graph.DependencyNode getNode(EnforcerRuleHelper helper) throws EnforcerRuleException
      Uses the EnforcerRuleHelper to populate the values of the DependencyTreeBuilder#buildDependencyTree(MavenProject, ArtifactRepository, ArtifactFactory, ArtifactMetadataSource, ArtifactFilter, ArtifactCollector) factory method.
      This method simply exists to hide all the ugly lookup that the EnforcerRuleHelper has to do.
      Parameters:
      helper -
      Returns:
      a Dependency Node which is the root of the project's dependency tree
      Throws:
      EnforcerRuleException
    • execute

      public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
      Description copied from interface: EnforcerRule
      This is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag if it should stop or just log the message as a warning.
      Specified by:
      execute in interface EnforcerRule
      Parameters:
      helper - The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • getFullArtifactName

      private String getFullArtifactName(org.apache.maven.artifact.Artifact artifact)
    • buildTreeString

      private StringBuilder buildTreeString(org.apache.maven.shared.dependency.graph.DependencyNode node)
    • getConvergenceErrorMsgs

      private List<String> getConvergenceErrorMsgs(List<List<org.apache.maven.shared.dependency.graph.DependencyNode>> errors)
    • buildConvergenceErrorMsg

      private String buildConvergenceErrorMsg(List<org.apache.maven.shared.dependency.graph.DependencyNode> nodeList)
    • getCacheId

      public String getCacheId()
      Description copied from interface: EnforcerRule
      If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters that allow multiple results of the same rule to be cached.
      Specified by:
      getCacheId in interface EnforcerRule
      Returns:
      id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique within a given rule implementation as the full key will be [classname]-[id]
    • isCacheable

      public boolean isCacheable()
      Description copied from interface: EnforcerRule
      This method tells the enforcer if the rule results may be cached. If the result is true, the results will be remembered for future executions in the same build (ie children). Subsequent iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be uncached further down the tree if needed.
      Specified by:
      isCacheable in interface EnforcerRule
      Returns:
      true if rule is cacheable
    • isResultValid

      public boolean isResultValid(EnforcerRule rule)
      Description copied from interface: EnforcerRule
      If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes the results of objects returned by the helper need to be queried. You may for example, store certain objects in your rule and then query them later.
      Specified by:
      isResultValid in interface EnforcerRule
      Parameters:
      rule - the last cached instance of the rule. This is to be used by the rule to potentially determine if the results are still valid (ie if the configuration has been overridden)
      Returns:
      true if the stored results are valid for the same id.