Class Resolver
java.lang.Object
de.iip_ecosphere.platform.tools.maven.dependencies.Resolver
Simple re-usable Maven artifact resolver.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) FileReturns the base directory of the local repository.private org.apache.maven.plugin.logging.LoggetLog()The log.(package private) static booleanDetermines whether an artifact/file with givennameshall be included (to a Jar, the resolved file).(package private) static booleanDetermines whether an artifact/file with givennameshall be included (to a Jar, the resolved file).(package private) static booleanisSnapshot(String name) Returns whether the given file/artifact name is a snapshot.(package private) static StringoptionalMarker(org.apache.maven.artifact.Artifact art) Returns an optional Maven coordinate addonCOORD_OPTIONAL_MARKERindicating an optional dependency.(package private) static StringremoveOptionalMarker(String coord) Removes a potential optional Maven coordinate addon indicating an optional dependency.(package private) static StringremoveScope(String coord, Consumer<String> scopeConsumer) Removes the optional scope from an extended Maven coordinate.(package private) StringResolves a list of artifacts to a composed path.(package private) Stringresolve(org.apache.maven.artifact.Artifact artifact) Resolves a single artifact.(package private) Fileresolve(org.eclipse.aether.artifact.DefaultArtifact artifact) Resolves an artifact via the repository system.(package private) FileresolveSpringBootLoader(org.apache.maven.project.MavenProject project) Resolves the spring boot loader from the oktoflow spring propertyorg.springframework.boot.version.(package private) StringresolveToUrl(org.apache.maven.artifact.Artifact artifact) Resolves a single artifact.(package private) StringresolveToUrl(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact) Resolves a single artifact item.(package private) StringresolveToUrl(org.eclipse.aether.artifact.DefaultArtifact artifact) Resolves an artifact to a download URL.static de.oktoflow.platform.tools.lib.loader.Constants.UnpackModetoUnpackMode(String mode) Turns a string to an unpack mode.(package private) org.eclipse.aether.artifact.DefaultArtifacttranslate(org.apache.maven.artifact.Artifact artifact) Translates a maven artifact to an Aether artifact.(package private) org.eclipse.aether.artifact.DefaultArtifacttranslate(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem artifact) Translates a maven artifact item to an Aether artifact.(package private) static StringtypeClassifier(org.apache.maven.artifact.Artifact art) Returns an optional type/classifier specification for Maven coordinates.(package private) <T> voidwriteResolvedFile(File file, Collection<T> items, Function<T, de.oktoflow.platform.tools.lib.loader.Constants.UnpackMode> unpackModeProvider, Function<T, String> resolutionProvider, Function<T, String> artifactIdProvider, Function<T, String> versionProvider, boolean plugin) Writes the dependency resolution file.
-
Field Details
-
DEFAULT_UNPACK_MODE
- See Also:
-
COORD_OPTIONAL_MARKER
- See Also:
-
log
private org.apache.maven.plugin.logging.Log log -
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 systemrepoSession- the repo sessionremoteRepositories- the remote repositorieslog- 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
Resolves a single artifact.- Parameters:
artifact- the artifact- Returns:
- the resolved path, empty if not resolvable
-
getLocalRepoBaseDir
File getLocalRepoBaseDir()Returns the base directory of the local repository.- Returns:
- the base directory
-
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
Resolves a single artifact.- Parameters:
artifact- the artifact- Returns:
- the resolved path, empty if not resolvable
-
resolveToUrl
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
Resolves a list of artifacts to a composed path.- Parameters:
artifacts- the artifacts, may be null- Returns:
- the path, may be empty
-
resolveSpringBootLoader
Resolves the spring boot loader from the oktoflow spring propertyorg.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, de.oktoflow.platform.tools.lib.loader.Constants.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 writeitems- the dependency itemsunpackModeProvider- provides the unpack mode for an item (useConstants.UnpackMode.RESOLVEfor all,Constants.UnpackMode.JARSfor 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 idversionProvider- resolves an item to its version
-
toUnpackMode
Turns a string to an unpack mode.- Parameters:
mode- the string, may be null, leading to a default value- Returns:
- the unpack mode
-
getLog
private org.apache.maven.plugin.logging.Log getLog()The log.- Returns:
- the log
-
isSnapshot
Returns whether the given file/artifact name is a snapshot.- Parameters:
name- the name- Returns:
truefor snapshot,falseelse
-
include
static boolean include(de.oktoflow.platform.tools.lib.loader.Constants.UnpackMode unpackMode, File file) Determines whether an artifact/file with givennameshall be included (to a Jar, the resolved file).- Parameters:
file- the file to take the name from- Returns:
truefor inclusion,falseelse
-
include
static boolean include(de.oktoflow.platform.tools.lib.loader.Constants.UnpackMode unpackMode, String name) Determines whether an artifact/file with givennameshall be included (to a Jar, the resolved file).- Parameters:
name- the name (prefix)- Returns:
truefor inclusion,falseelse
-
typeClassifier
Returns an optional type/classifier specification for Maven coordinates.- Parameters:
art- the artifact to take the data from- Returns:
- the type/classifier infix specification or an empty string
-
optionalMarker
Returns an optional Maven coordinate addonCOORD_OPTIONAL_MARKERindicating an optional dependency.- Parameters:
art- the artifact to take the data from- Returns:
- the addon or an empty string if not optional
- See Also:
-
removeOptionalMarker
Removes a potential optional Maven coordinate addon indicating an optional dependency.- Parameters:
coord- the coordinate- Returns:
- the coordinate potentially with marker removed. There was a marker if input/output differs.
- See Also:
-
removeScope
Removes the optional scope from an extended Maven coordinate.- Parameters:
coord- the coordinatescopeConsumer- the scope consumer, may be null for none- Returns:
- the coordinate without scope
-