Class ArtifactUtils
java.lang.Object
org.apache.maven.enforcer.rules.utils.ArtifactUtils
- Since:
- 3.0.0
- Author:
- Robert Scholte
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 patternsstatic boolean
matchDependencyArtifact
(org.apache.maven.artifact.Artifact artifact, Collection<String> patterns) Checks if the given dependency artifact matches the given collection of patternsstatic org.apache.maven.artifact.Artifact
toArtifact
(org.eclipse.aether.graph.DependencyNode node) ConvertsDependencyNode
toArtifact
; in comparison toRepositoryUtils.toArtifact(org.eclipse.aether.artifact.Artifact)
, this method assignsArtifact.getScope()
andArtifact.isOptional()
based on the dependency information from the node.
-
Constructor Details
-
ArtifactUtils
public ArtifactUtils()
-
-
Method Details
-
toArtifact
public static org.apache.maven.artifact.Artifact toArtifact(org.eclipse.aether.graph.DependencyNode node) ConvertsDependencyNode
toArtifact
; in comparison toRepositoryUtils.toArtifact(org.eclipse.aether.artifact.Artifact)
, this method assignsArtifact.getScope()
andArtifact.isOptional()
based on the dependency information from the node.- Parameters:
node
-DependencyNode
to convert toArtifact
- 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 patternspatterns
- patterns to match against the artifacts- Returns:
- a set containing artifacts matching one of the patterns or
null
- Throws:
EnforcerRuleException
- the enforcer rule exception
-
matchDependencyArtifact
public static boolean matchDependencyArtifact(org.apache.maven.artifact.Artifact artifact, Collection<String> patterns) Checks if the given dependency artifact matches the given collection of patterns- Parameters:
artifact
- dependency artifact to match against patternspatterns
- patterns to match against the artifacts- Returns:
true
if the given artifact matches the set of patterns
-
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 formatgroupId: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
-