java.lang.Object
de.iip_ecosphere.platform.tools.maven.dependencies.Resolver

class Resolver extends Object
Simple re-usable Maven artifact resolver.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    private org.apache.maven.plugin.logging.Log
     
    private List<org.eclipse.aether.repository.RemoteRepository>
     
    private org.eclipse.aether.RepositorySystemSession
     
    private org.eclipse.aether.RepositorySystem
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Resolver(org.eclipse.aether.RepositorySystem repoSystem, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.apache.maven.plugin.logging.Log log)
    Creates a resolver instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    private org.apache.maven.plugin.logging.Log
    The log.
    (package private) static boolean
    include(Resolver.UnpackMode unpackMode, File file)
    Determines whether an artifact/file with given name shall be included (to a Jar, the resolved file).
    (package private) static boolean
    include(Resolver.UnpackMode unpackMode, String name)
    Determines whether an artifact/file with given name shall be included (to a Jar, the resolved file).
    (package private) static boolean
    Returns whether the given file/artifact name is a snapshot.
    (package private) String
    resolve(List<org.apache.maven.artifact.Artifact> artifacts)
    Resolves a list of artifacts to a composed path.
    (package private) String
    resolve(org.apache.maven.artifact.Artifact artifact)
    Resolves a single artifact.
    (package private) File
    resolve(org.eclipse.aether.artifact.DefaultArtifact artifact)
    Resolves an artifact via the repository system.
    (package private) File
    resolveSpringBootLoader(org.apache.maven.project.MavenProject project)
    Resolves the spring boot loader from the oktoflow spring property org.springframework.boot.version.
    (package private) String
    resolveToUrl(org.apache.maven.artifact.Artifact artifact)
    Resolves a single artifact.
    (package private) String
    resolveToUrl(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact)
    Resolves a single artifact item.
    (package private) String
    resolveToUrl(org.eclipse.aether.artifact.DefaultArtifact artifact)
    Resolves an artifact to a download URL.
    (package private) static Resolver.UnpackMode
    Turns a string to an unpack mode.
    (package private) org.eclipse.aether.artifact.DefaultArtifact
    translate(org.apache.maven.artifact.Artifact artifact)
    Translates a maven artifact to an Aether artifact.
    (package private) org.eclipse.aether.artifact.DefaultArtifact
    translate(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact)
    Translates a maven artifact item to an Aether artifact.
    (package private) <T> void
    writeResolvedFile(File file, Collection<T> items, Function<T,Resolver.UnpackMode> unpackModeProvider, Function<T,String> resolutionProvider, Function<T,String> artifactIdProvider, Function<T,String> versionProvider, boolean plugin)
    Writes the dependency resolution file.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_UNPACK_MODE

      public static final String DEFAULT_UNPACK_MODE
      See Also:
    • log

      private org.apache.maven.plugin.logging.Log log
    • remoteRepositories

      private List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories
    • repoSession

      private org.eclipse.aether.RepositorySystemSession repoSession
    • repoSystem

      private org.eclipse.aether.RepositorySystem repoSystem
  • Constructor Details

    • Resolver

      Resolver(org.eclipse.aether.RepositorySystem repoSystem, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.apache.maven.plugin.logging.Log log)
      Creates a resolver instance.
      Parameters:
      repoSystem - the repo system
      repoSession - the repo session
      remoteRepositories - the remote repositories
      log - the logger
  • Method Details

    • translate

      org.eclipse.aether.artifact.DefaultArtifact translate(org.apache.maven.artifact.Artifact artifact)
      Translates a maven artifact to an Aether artifact.
      Parameters:
      artifact - the maven artifact
      Returns:
      the aether artifact
    • translate

      org.eclipse.aether.artifact.DefaultArtifact translate(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact)
      Translates a maven artifact item to an Aether artifact.
      Parameters:
      artifact - the maven artifact
      Returns:
      the aether artifact
    • resolve

      String resolve(org.apache.maven.artifact.Artifact artifact)
      Resolves a single artifact.
      Parameters:
      artifact - the artifact
      Returns:
      the resolved path, empty if not resolvable
    • resolve

      File resolve(org.eclipse.aether.artifact.DefaultArtifact artifact) throws org.eclipse.aether.resolution.ArtifactResolutionException
      Resolves an artifact via the repository system.
      Parameters:
      artifact - the artifact to resolve
      Returns:
      the resolved path
      Throws:
      org.eclipse.aether.resolution.ArtifactResolutionException - if resolution fails
    • resolveToUrl

      String resolveToUrl(org.apache.maven.artifact.Artifact artifact)
      Resolves a single artifact.
      Parameters:
      artifact - the artifact
      Returns:
      the resolved path, empty if not resolvable
    • resolveToUrl

      String resolveToUrl(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact)
      Resolves a single artifact item.
      Parameters:
      artifact - the artifact
      Returns:
      the resolved path, empty if not resolvable
    • resolveToUrl

      String resolveToUrl(org.eclipse.aether.artifact.DefaultArtifact artifact) throws org.eclipse.aether.resolution.ArtifactResolutionException
      Resolves an artifact to a download URL.
      Parameters:
      artifact - the artifact to resolve
      Returns:
      the download URL, may be null for none
      Throws:
      org.eclipse.aether.resolution.ArtifactResolutionException
    • resolve

      String resolve(List<org.apache.maven.artifact.Artifact> artifacts)
      Resolves a list of artifacts to a composed path.
      Parameters:
      artifacts - the artifacts, may be null
      Returns:
      the path, may be empty
    • resolveSpringBootLoader

      File resolveSpringBootLoader(org.apache.maven.project.MavenProject project)
      Resolves the spring boot loader from the oktoflow spring property org.springframework.boot.version.
      Parameters:
      project - the Maven project to resolve on
      Returns:
      the resolved file, null if there is none
    • writeResolvedFile

      <T> void writeResolvedFile(File file, Collection<T> items, Function<T,Resolver.UnpackMode> unpackModeProvider, Function<T,String> resolutionProvider, Function<T,String> artifactIdProvider, Function<T,String> versionProvider, boolean plugin)
      Writes the dependency resolution file.
      Type Parameters:
      T - the type of dependency item
      Parameters:
      file - the file to write
      items - the dependency items
      unpackModeProvider - provides the unpack mode for an item (use Resolver.UnpackMode.RESOLVE for all, Resolver.UnpackMode.JARS for none)
      resolutionProvider - resolves an item to its dependency URL (may lead to an empty or null value, ignored then)
      artifactIdProvider - resolves an item to its artifact id
      versionProvider - resolves an item to its version
    • getLog

      private org.apache.maven.plugin.logging.Log getLog()
      The log.
      Returns:
      the log
    • isSnapshot

      static boolean isSnapshot(String name)
      Returns whether the given file/artifact name is a snapshot.
      Parameters:
      name - the name
      Returns:
      true for snapshot, false else
    • include

      static boolean include(Resolver.UnpackMode unpackMode, File file)
      Determines whether an artifact/file with given name shall be included (to a Jar, the resolved file).
      Parameters:
      file - the file to take the name from
      Returns:
      true for inclusion, false else
    • include

      static boolean include(Resolver.UnpackMode unpackMode, String name)
      Determines whether an artifact/file with given name shall be included (to a Jar, the resolved file).
      Parameters:
      name - the name (prefix)
      Returns:
      true for inclusion, false else
    • toUnpackMode

      static Resolver.UnpackMode toUnpackMode(String mode)
      Turns a string to an unpack mode.
      Parameters:
      mode - the string, may be null then the unpack mode of DEFAULT_UNPACK_MODE
      Returns:
      the unpack mode