Class DependencyResolver

java.lang.Object
de.iip_ecosphere.platform.configuration.maven.DependencyResolver

public class DependencyResolver extends Object
Simple Maven (snapshot) dependency resolver. For sure, there are better and easier ways...
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Information needed for dependency resolution.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private Set<org.apache.maven.artifact.Artifact>
     
    private static final org.apache.maven.artifact.handler.ArtifactHandler
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a dependency resolver with caller information.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the resolver for reuse.
    private org.eclipse.aether.artifact.DefaultArtifact
    createAetherArtifact(org.apache.maven.artifact.Artifact artifact)
    Creates an aether artifact for a maven artifact.
    static org.apache.maven.artifact.Artifact
    createArtifact(String artifact, String scope)
    Creates an artifact instance.
    org.apache.maven.project.MavenProject
    createMavenProject(org.apache.maven.artifact.Artifact artifact)
    Creates a Maven project instance.
    private boolean
    hasChanged(org.apache.maven.artifact.Artifact artifact, Predicate<File> since)
    Returns whether the given (snapshot) artifact or its dependencies has changed since.
    boolean
    Returns whether at least one of the given (snapshot) artifacts or its (snapshot) dependencies has changed since.
    org.apache.maven.artifact.Artifact
    resolve(org.apache.maven.artifact.Artifact artifact)
    Tries to resolve artifact.

    Methods inherited from class java.lang.Object

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

    • JAR_HANDLER

      private static final org.apache.maven.artifact.handler.ArtifactHandler JAR_HANDLER
    • caller

      private DependencyResolver.Caller caller
    • done

      private Set<org.apache.maven.artifact.Artifact> done
  • Constructor Details

    • DependencyResolver

      public DependencyResolver(DependencyResolver.Caller caller)
      Creates a dependency resolver with caller information.
      Parameters:
      caller - the caller
  • Method Details

    • resolve

      public org.apache.maven.artifact.Artifact resolve(org.apache.maven.artifact.Artifact artifact)
      Tries to resolve artifact.
      Parameters:
      artifact - the artifact to resolve
      Returns:
      the resolved artifact, null for none
    • createAetherArtifact

      private org.eclipse.aether.artifact.DefaultArtifact createAetherArtifact(org.apache.maven.artifact.Artifact artifact)
      Creates an aether artifact for a maven artifact.
      Parameters:
      artifact - the maven artifact
      Returns:
      the aether artifact
    • hasChanged

      private boolean hasChanged(org.apache.maven.artifact.Artifact artifact, Predicate<File> since)
      Returns whether the given (snapshot) artifact or its dependencies has changed since. Stops artifact checking/resolution as soon as possible.
      Parameters:
      artifact - the artifact
      since - the change predicate
      Returns:
      true if one artifact changed, false else
    • createMavenProject

      public org.apache.maven.project.MavenProject createMavenProject(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.project.ProjectBuildingException
      Creates a Maven project instance.
      Parameters:
      artifact - the artifact to return the Maven project instance for
      Returns:
      the Maven project instance, may be null if artifact is null
      Throws:
      org.apache.maven.project.ProjectBuildingException - if the project cannot be created
    • haveDependenciesChangedSince

      public boolean haveDependenciesChangedSince(List<String> artifacts, Predicate<File> since)
      Returns whether at least one of the given (snapshot) artifacts or its (snapshot) dependencies has changed since. Stops artifact checking/resolution as soon as possible.
      Parameters:
      artifacts - the artifacts
      since - the change predicate
      Returns:
      true if one artifact changed, false else
    • createArtifact

      public static org.apache.maven.artifact.Artifact createArtifact(String artifact, String scope)
      Creates an artifact instance.
      Parameters:
      artifact - the textual artifact specification
      scope - the resolution scope
      Returns:
      the artifact or null if none can be created
    • clear

      public void clear()
      Clears the resolver for reuse.