Class ArtifactUtils

java.lang.Object
org.apache.maven.enforcer.rules.utils.ArtifactUtils

public final class ArtifactUtils extends Object
Since:
3.0.0
Author:
Robert Scholte
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    compareDependency(String pattern, org.apache.maven.artifact.Artifact artifact)
    Compares the given pattern against the given artifact.
    static Set<org.apache.maven.artifact.Artifact>
    filterDependencyArtifacts(Set<org.apache.maven.artifact.Artifact> dependencies, Collection<String> patterns)
    Returns a subset of dependency artifacts that match the given collection of patterns
    static Predicate<org.apache.maven.artifact.Artifact>
    Prepares patterns directly into a reusable predicate.
    static org.apache.maven.artifact.Artifact
    toArtifact(org.eclipse.aether.graph.Dependency dependency)
    Converts Dependency to Artifact; in comparison to RepositoryUtils.toArtifact(org.eclipse.aether.artifact.Artifact), this method assigns Artifact.getScope() and Artifact.isOptional() based on the dependency information from the node.
    static org.apache.maven.artifact.Artifact
    toArtifact(org.eclipse.aether.graph.DependencyNode node)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • toArtifact

      public static org.apache.maven.artifact.Artifact toArtifact(org.eclipse.aether.graph.DependencyNode node)
    • toArtifact

      public static org.apache.maven.artifact.Artifact toArtifact(org.eclipse.aether.graph.Dependency dependency)
      Converts Dependency to Artifact; in comparison to RepositoryUtils.toArtifact(org.eclipse.aether.artifact.Artifact), this method assigns Artifact.getScope() and Artifact.isOptional() based on the dependency information from the node.
      Parameters:
      dependency - Dependency to convert to Artifact
      Returns:
      target artifact
    • filterDependencyArtifacts

      public static Set<org.apache.maven.artifact.Artifact> filterDependencyArtifacts(Set<org.apache.maven.artifact.Artifact> dependencies, Collection<String> patterns) throws EnforcerRuleException
      Returns a subset of dependency artifacts that match the given collection of patterns
      Parameters:
      dependencies - dependency artifacts to match against patterns
      patterns - patterns to match against the artifacts
      Returns:
      a set containing artifacts matching one of the patterns or null
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • prepareDependencyArtifactMatcher

      public static Predicate<org.apache.maven.artifact.Artifact> prepareDependencyArtifactMatcher(Collection<String> patterns)
      Prepares patterns directly into a reusable predicate. This can improve efficiency where there are lots of patterns and/or artifacts to match.
      Parameters:
      patterns - the patterns to use for the predicate
      Returns:
      a re-usable predicate.
    • compareDependency

      public static boolean compareDependency(String pattern, org.apache.maven.artifact.Artifact artifact)
      Compares the given pattern against the given artifact. The pattern should follow the format groupId:artifactId:version:type:scope:classifier.
      Parameters:
      pattern - The pattern to compare the artifact with.
      artifact - the artifact
      Returns:
      true if the artifact matches one of the patterns