Class RequireUpperBoundDeps

All Implemented Interfaces:
EnforcerRule, EnforcerRule2

public class RequireUpperBoundDeps extends AbstractNonCacheableEnforcerRule
Rule to enforce that the resolved dependency is also the most recent one of all transitive dependencies.
Since:
1.1
  • Field Details

    • log

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

      private static org.codehaus.plexus.i18n.I18N i18n
    • uniqueVersions

      private boolean uniqueVersions
      Since:
      1.3
  • Constructor Details

    • RequireUpperBoundDeps

      public RequireUpperBoundDeps()
  • Method Details

    • setUniqueVersions

      public void setUniqueVersions(boolean uniqueVersions)
      Set to true if timestamped snapshots should be used.
      Parameters:
      uniqueVersions -
      Since:
      1.3
    • 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 - when the build should fail
    • 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.
      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
    • buildErrorMessages

      private List<String> buildErrorMessages(List<List<org.apache.maven.shared.dependency.graph.DependencyNode>> conflicts)
    • buildErrorMessage

      private String buildErrorMessage(List<org.apache.maven.shared.dependency.graph.DependencyNode> conflict)
    • buildTreeString

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

      private String getFullArtifactName(org.apache.maven.shared.dependency.graph.DependencyNode node, boolean usePremanaged)