Class ArtifactHelpers


  • public class ArtifactHelpers
    extends Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean artifactIsNotExcluded​(Collection<org.eclipse.aether.graph.Exclusion> exclusions, org.eclipse.aether.artifact.Artifact artifact)
      Check that an artifact is not excluded
      static boolean artifactsAreMatchingTypes​(org.eclipse.aether.artifact.Artifact first, org.eclipse.aether.artifact.Artifact second)
      Checks to see if two artifacts are of the same type (but not necessarily the same version)
      static boolean containsExclusion​(Collection<org.eclipse.aether.graph.Exclusion> exclusions, org.eclipse.aether.graph.Exclusion exclusion)
      Exclusive can be specified by wildcard: -- groupId:artifactId:*:* -- groupId:*:*:*
      static List<String> createDefaultJmeterArtifactsArray​(String jmeterVersion)
      Create a default Array of JMeter artifact coordinates
      static boolean isArtifactALibrary​(org.eclipse.aether.artifact.Artifact artifact)
      Check to see if artifact is a library
      static boolean isArtifactIsOlderThanArtifact​(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.artifact.Artifact comparisonArtifact)
      Check to see if a specified artifact is the same version, or a newer version that the comparative artifact
      static org.eclipse.aether.artifact.Artifact resolveArtifactVersion​(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, List<org.eclipse.aether.repository.RemoteRepository> repositoryList, org.eclipse.aether.artifact.Artifact desiredArtifact)
      Ensure we have a valid version number to download an artifact.
      static Set<org.eclipse.aether.graph.Exclusion> setupExcludedArtifacts​(List<String> excludedArtifacts)
      Build up an exclusion set
    • Method Detail

      • setupExcludedArtifacts

        public static Set<org.eclipse.aether.graph.Exclusion> setupExcludedArtifacts​(List<String> excludedArtifacts)
                                                                              throws org.apache.maven.plugin.MojoExecutionException
        Build up an exclusion set
        Parameters:
        excludedArtifacts - List of artifact coords patterns in the format <groupId>:<artifactId>[:<extension>][:<classifier>]
        Returns:
        Set<Exclusion>
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any patterns are invalid
      • containsExclusion

        public static boolean containsExclusion​(Collection<org.eclipse.aether.graph.Exclusion> exclusions,
                                                org.eclipse.aether.graph.Exclusion exclusion)
        Exclusive can be specified by wildcard: -- groupId:artifactId:*:* -- groupId:*:*:*

        And in general, to require a strict match up to the version and the classifier is not necessary

        TODO: the correct fix would be to rewrite # equals (Object), but what about the boundary case: If contains (id1: *: *: *, id1: id2: *: *) == true, then that's equals ?? TODO: there must be useful code in Aether or maven on this topic

        Parameters:
        exclusions - Collection of exclusions
        exclusion - Specific exclusion to search through collection for
        Returns:
        boolean
      • artifactIsNotExcluded

        public static boolean artifactIsNotExcluded​(Collection<org.eclipse.aether.graph.Exclusion> exclusions,
                                                    org.eclipse.aether.artifact.Artifact artifact)
        Check that an artifact is not excluded
        Parameters:
        exclusions - Collection of exclusions
        artifact - Specific artifact to search through collection for
        Returns:
        boolean
      • createDefaultJmeterArtifactsArray

        public static List<String> createDefaultJmeterArtifactsArray​(String jmeterVersion)
        Create a default Array of JMeter artifact coordinates
        Parameters:
        jmeterVersion - JMeter version for artifacts
        Returns:
        List<String> of artifact coords
      • isArtifactALibrary

        public static boolean isArtifactALibrary​(org.eclipse.aether.artifact.Artifact artifact)
        Check to see if artifact is a library
        Parameters:
        artifact - Artifact
        Returns:
        boolean if true
      • isArtifactIsOlderThanArtifact

        public static boolean isArtifactIsOlderThanArtifact​(org.eclipse.aether.artifact.Artifact artifact,
                                                            org.eclipse.aether.artifact.Artifact comparisonArtifact)
                                                     throws org.eclipse.aether.version.InvalidVersionSpecificationException
        Check to see if a specified artifact is the same version, or a newer version that the comparative artifact
        Parameters:
        artifact - An artifact
        comparisonArtifact - another Artifact to compare with.
        Returns:
        true if artifact is the same or a higher version. False if the artifact is a lower version
        Throws:
        org.eclipse.aether.version.InvalidVersionSpecificationException - Unable to get artifact versions
      • artifactsAreMatchingTypes

        public static boolean artifactsAreMatchingTypes​(org.eclipse.aether.artifact.Artifact first,
                                                        org.eclipse.aether.artifact.Artifact second)
        Checks to see if two artifacts are of the same type (but not necessarily the same version)
        Parameters:
        first - An Artifact
        second - A comparison Artifact
        Returns:
        true if the Artifacts match, false if they don't
      • resolveArtifactVersion

        public static org.eclipse.aether.artifact.Artifact resolveArtifactVersion​(org.eclipse.aether.RepositorySystem repositorySystem,
                                                                                  org.eclipse.aether.RepositorySystemSession repositorySystemSession,
                                                                                  List<org.eclipse.aether.repository.RemoteRepository> repositoryList,
                                                                                  org.eclipse.aether.artifact.Artifact desiredArtifact)
                                                                           throws org.eclipse.aether.resolution.VersionRangeResolutionException
        Ensure we have a valid version number to download an artifact. This will check to see if the version number supplied is a range or not. If it is a range it will replace the range with the highest version (inside the range) available
        Parameters:
        repositorySystem - system repositories
        repositorySystemSession - session repositories
        repositoryList - list of repositories to try and download artifacts from
        desiredArtifact - the artifact we want to download
        Returns:
        the artifact with the version number set to a static version number instead of a range
        Throws:
        org.eclipse.aether.resolution.VersionRangeResolutionException - Thrown if we cannot resolve any versions