Class AetherBasedResolver
- java.lang.Object
-
- org.ops4j.pax.url.mvn.internal.AetherBasedResolver
-
- All Implemented Interfaces:
Closeable,AutoCloseable,MavenResolver
public class AetherBasedResolver extends Object implements MavenResolver
MavenResolverbased on Apache Maven Resolver (formerly - Eclipse Aether Resolver (formerly - Sonatype Aether Resolver)).The resolution process is almost the same as in usual
mvninvocation with one big difference. While in pure Maven, remote repositories are used to download the artifacts to local repository if not already available, in Pax URL Aether, there's an initial resolution attempt based on default repositories which are treated as local repositories without write access. This is important for managing separate directories with Maven-like structure - for example in$KARAF_HOME/system.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAetherBasedResolver.LocalRepositoryWithConfigCombination ofLocalRepositoryandMavenRepositoryURL-
Nested classes/interfaces inherited from interface org.ops4j.pax.url.mvn.MavenResolver
MavenResolver.RetryChance
-
-
Constructor Summary
Constructors Constructor Description AetherBasedResolver(MavenConfiguration configuration)Create a AetherBasedResolverAetherBasedResolver(MavenConfiguration configuration, MirrorInfo mirror)Create a AetherBasedResolver
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<org.eclipse.aether.repository.RemoteRepository>assignMirrorsAndProxies(org.eclipse.aether.RepositorySystemSession session, List<org.eclipse.aether.repository.RemoteRepository> repositories)Pax URL 2.6 manually checked mirros, proxies and authentication configuration to replace list of targetrepositorieswith mirrored/proxied ones.voidclose()protected org.eclipse.aether.RepositoryExceptionfindAetherException(Exception e)Find top-most Aether exceptionMavenResolver.RetryChanceisRetryableException(Exception exception)Returns a hint about possible retry of operation that ended withexceptionFileresolve(String url)Resolve and download a maven based urlFileresolve(String url, Exception previousException)Resolve and download a maven based url - possibly as another attempt.Fileresolve(String groupId, String artifactId, String classifier, String extension, String version)Resolve and download an artifactFileresolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException)Resolve and download an artifact - possibly as another attempt.Fileresolve(String groupId, String artifactId, String classifier, String extension, String version, MavenRepositoryURL url, Exception previousException)Resolve artifact, possibly checking extra (comparing to configured repositories)MavenRepositoryURLobtained frommvn:URI.Fileresolve(List<AetherBasedResolver.LocalRepositoryWithConfig> defaultRepositories, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.eclipse.aether.artifact.Artifact artifact)Main resolution method that operates on passed default and remote repositories and doesn't determine the checked repositories on its own.Fileresolve(org.eclipse.aether.artifact.Artifact artifact, MavenRepositoryURL url, Exception previousException)Main resolution method that resolves artifact using data fromArtifactand repositories prepared from global configuration.FileresolveMetadata(String groupId, String artifactId, String type, String version)Resolve the maven metadata xml for the specified groupId:artifactId:versionFileresolveMetadata(String groupId, String artifactId, String type, String version, Exception previousException)Resolve the maven metadata xml for the specified groupId:artifactId:version - possibly as another attempt.protected ThrowablerootException(Exception ex)Find root exceptionvoidupload(String groupId, String artifactId, String classifier, String extension, String version, File file)Install the specified artifact in the local repositoryvoiduploadMetadata(String groupId, String artifactId, String type, String version, File artifact)Install the specified artifact metadata in the local repository
-
-
-
Constructor Detail
-
AetherBasedResolver
public AetherBasedResolver(MavenConfiguration configuration)
Create a AetherBasedResolver- Parameters:
configuration- (must be not null)
-
AetherBasedResolver
public AetherBasedResolver(MavenConfiguration configuration, MirrorInfo mirror)
Create a AetherBasedResolver- Parameters:
configuration- (must be not null)mirror-
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
resolve
public File resolve(String url) throws IOException
Description copied from interface:MavenResolverResolve and download a maven based url- Specified by:
resolvein interfaceMavenResolver- Throws:
IOException
-
resolve
public File resolve(String url, Exception previousException) throws IOException
Description copied from interface:MavenResolverResolve and download a maven based url - possibly as another attempt. SpecifyingpreviousExceptionis a hint for resolver.- Specified by:
resolvein interfaceMavenResolver- Throws:
IOException
-
resolve
public File resolve(String groupId, String artifactId, String classifier, String extension, String version) throws IOException
Description copied from interface:MavenResolverResolve and download an artifact- Specified by:
resolvein interfaceMavenResolver- Throws:
IOException
-
resolve
public File resolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException) throws IOException
Description copied from interface:MavenResolverResolve and download an artifact - possibly as another attempt. SpecifyingpreviousExceptionis a hint for resolver.- Specified by:
resolvein interfaceMavenResolver- Throws:
IOException
-
resolve
public File resolve(String groupId, String artifactId, String classifier, String extension, String version, MavenRepositoryURL url, Exception previousException) throws IOException
Resolve artifact, possibly checking extra (comparing to configured repositories)MavenRepositoryURLobtained frommvn:URI.- Parameters:
groupId-artifactId-classifier-extension-version-url- additional Maven Repository URL to checkpreviousException-- Returns:
- Throws:
IOException
-
resolve
public File resolve(org.eclipse.aether.artifact.Artifact artifact, MavenRepositoryURL url, Exception previousException) throws IOException
Main resolution method that resolves artifact using data fromArtifactand repositories prepared from global configuration.- Parameters:
artifact-url- extra URL for remote repository to check if the originalmvn:URI included source repositorypreviousException-- Returns:
- Throws:
IOException
-
resolve
public File resolve(List<AetherBasedResolver.LocalRepositoryWithConfig> defaultRepositories, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.eclipse.aether.artifact.Artifact artifact) throws IOException
Main resolution method that operates on passed default and remote repositories and doesn't determine the checked repositories on its own.
This is the main method that implements Pax URL resolution, which involves a set of default repositories and defaults to remote repository resolution if artifact is not found.
This method requires that
RemoteRepositoryobjects used are already processed (mirrors, proxies, auth).- Parameters:
defaultRepositories-remoteRepositories-artifact-- Returns:
- Throws:
IOException
-
resolveMetadata
public File resolveMetadata(String groupId, String artifactId, String type, String version) throws IOException
Description copied from interface:MavenResolverResolve the maven metadata xml for the specified groupId:artifactId:version- Specified by:
resolveMetadatain interfaceMavenResolver- Throws:
IOException
-
resolveMetadata
public File resolveMetadata(String groupId, String artifactId, String type, String version, Exception previousException) throws IOException
Description copied from interface:MavenResolverResolve the maven metadata xml for the specified groupId:artifactId:version - possibly as another attempt. SpecifyingpreviousExceptionis a hint for resolver.- Specified by:
resolveMetadatain interfaceMavenResolver- Throws:
IOException
-
upload
public void upload(String groupId, String artifactId, String classifier, String extension, String version, File file) throws IOException
Description copied from interface:MavenResolverInstall the specified artifact in the local repository- Specified by:
uploadin interfaceMavenResolver- Throws:
IOException
-
uploadMetadata
public void uploadMetadata(String groupId, String artifactId, String type, String version, File artifact) throws IOException
Description copied from interface:MavenResolverInstall the specified artifact metadata in the local repository- Specified by:
uploadMetadatain interfaceMavenResolver- Throws:
IOException
-
isRetryableException
public MavenResolver.RetryChance isRetryableException(Exception exception)
Description copied from interface:MavenResolverReturns a hint about possible retry of operation that ended withexception- Specified by:
isRetryableExceptionin interfaceMavenResolver- Returns:
-
findAetherException
protected org.eclipse.aether.RepositoryException findAetherException(Exception e)
Find top-most Aether exception- Parameters:
e-- Returns:
-
rootException
protected Throwable rootException(Exception ex)
Find root exception- Parameters:
ex-- Returns:
-
assignMirrorsAndProxies
public List<org.eclipse.aether.repository.RemoteRepository> assignMirrorsAndProxies(org.eclipse.aether.RepositorySystemSession session, List<org.eclipse.aether.repository.RemoteRepository> repositories)
Pax URL 2.6 manually checked mirros, proxies and authentication configuration to replace list of target
repositorieswith mirrored/proxied ones.Here we'll use
RepositorySystem.newResolutionRepositories(org.eclipse.aether.RepositorySystemSession, java.util.List<org.eclipse.aether.repository.RemoteRepository>). If passes session is null, a static session is used that satisfies requirements of underlying resolver mechanisms (like getting global update/checksum policies).- Parameters:
session-repositories-- Returns:
-
-