public class MavenArtifactClassLoader extends URLClassLoader
URLClassLoader
that uses the Maven
Resolver API to resolve artifacts from Maven repositories.Constructor and Description |
---|
MavenArtifactClassLoader(RepositorySystem repositorySystem,
RepositorySystemSession session,
DependencyRequest dependencyRequest)
Creates a new
MavenArtifactClassLoader . |
MavenArtifactClassLoader(RepositorySystem repositorySystem,
RepositorySystemSession session,
DependencyRequest dependencyRequest,
ClassLoader parentClassLoader)
Creates a new
MavenArtifactClassLoader . |
MavenArtifactClassLoader(RepositorySystem repositorySystem,
RepositorySystemSession session,
DependencyRequest dependencyRequest,
ClassLoader parentClassLoader,
URLStreamHandlerFactory urlStreamHandlerFactory)
Creates a new
MavenArtifactClassLoader . |
Modifier and Type | Method and Description |
---|---|
static DependencyRequest |
getDependencyRequest(CollectRequest collectRequest)
|
static DependencyRequest |
getDependencyRequest(Set<? extends Artifact> artifacts,
List<RemoteRepository> remoteRepositories)
Given a
Set of Artifact s and a List of
RemoteRepository instances representing repositories from
which they might be resolved, creates and returns a DependencyRequest for their resolution, using runtime scope. |
static DependencyRequest |
getDependencyRequest(Set<? extends Artifact> artifacts,
String scope,
List<RemoteRepository> remoteRepositories)
Given a
Set of Artifact s and a List of
RemoteRepository instances representing repositories from
which they might be resolved, creates and returns a DependencyRequest for their resolution in the supplied scope. |
static DependencyRequest |
getDependencyRequest(String classpathLikeString,
List<RemoteRepository> remoteRepositories)
Returns a non-
null DependencyRequest by parsing
the supplied classpath-like String for Maven artifact
coordinates, and then invoking and returning the result of the
getDependencyRequest(Set, List) method. |
static Collection<? extends URL> |
getUrls(RepositorySystem repositorySystem,
RepositorySystemSession session,
DependencyRequest dependencyRequest)
Returns a
Collection of (file ) URL s that
results from resolution of the dependencies described by the
supplied DependencyRequest . |
String |
toClasspath()
Returns a non-
null String with a classpath-like
format that can represent this MavenArtifactClassLoader 's URL s. |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
defineClass, defineClass
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public MavenArtifactClassLoader(RepositorySystem repositorySystem, RepositorySystemSession session, DependencyRequest dependencyRequest) throws DependencyResolutionException
MavenArtifactClassLoader
.repositorySystem
- the RepositorySystem
responsible
for resolving artifacts; must not be null
session
- the RepositorySystemSession
governing
certain aspects of the resolution process; must not be null
dependencyRequest
- the DependencyRequest
that
describes what artifacts should be resolved; must not be null
NullPointerException
- if a parameter that must not be
null
is discovered to be null
DependencyResolutionException
- if there was a problem
resolving dependenciesgetUrls(RepositorySystem, RepositorySystemSession,
DependencyRequest)
,
getDependencyRequest(String, List)
,
URLClassLoader.URLClassLoader(URL[])
public MavenArtifactClassLoader(RepositorySystem repositorySystem, RepositorySystemSession session, DependencyRequest dependencyRequest, ClassLoader parentClassLoader) throws DependencyResolutionException
MavenArtifactClassLoader
.repositorySystem
- the RepositorySystem
responsible
for resolving artifacts; must not be null
session
- the RepositorySystemSession
governing
certain aspects of the resolution process; must not be null
dependencyRequest
- the DependencyRequest
that
describes what artifacts should be resolved; must not be null
parentClassLoader
- the ClassLoader
that will
parent this one; may be
null
NullPointerException
- if a parameter that must not be
null
is discovered to be null
DependencyResolutionException
- if there was a problem
resolving dependenciesgetUrls(RepositorySystem, RepositorySystemSession,
DependencyRequest)
,
getDependencyRequest(String, List)
,
URLClassLoader.URLClassLoader(URL[], ClassLoader)
public MavenArtifactClassLoader(RepositorySystem repositorySystem, RepositorySystemSession session, DependencyRequest dependencyRequest, ClassLoader parentClassLoader, URLStreamHandlerFactory urlStreamHandlerFactory) throws DependencyResolutionException
MavenArtifactClassLoader
.repositorySystem
- the RepositorySystem
responsible
for resolving artifacts; must not be null
session
- the RepositorySystemSession
governing
certain aspects of the resolution process; must not be null
dependencyRequest
- the DependencyRequest
that
describes what artifacts should be resolved; must not be null
parentClassLoader
- the ClassLoader
that will
parent this one; may be
null
urlStreamHandlerFactory
- the URLStreamHandlerFactory
to create URLStreamHandler
s for
the URL
s URL
s that
constitute this MavenArtifactClassLoader
's
classpath; URLClassLoader
does not define whether this
can be null
or notNullPointerException
- if a parameter that must not be
null
is discovered to be null
DependencyResolutionException
- if there was a problem
resolving dependenciesgetUrls(RepositorySystem, RepositorySystemSession,
DependencyRequest)
,
getDependencyRequest(String, List)
,
URLClassLoader.URLClassLoader(URL[], ClassLoader,
URLStreamHandlerFactory)
public String toClasspath()
null
String
with a classpath-like
format that can represent this MavenArtifactClassLoader
's URL
s.
The format of the String
that is returned is exactly
like a classpath string appropriate for the current platform with
the exception that the platform-specific classpath separator is
doubled if any of the URL
s belonging to this MavenArtifactClassLoader
is not a
file
URL.
For any given URL
, the returned String
will
represent it as its String
form, unless it has a protocol equal to file
, in which case
will represent it as its path.
null
classpath-like String
(with
doubled classpath separators) consisting of this MavenArtifactClassLoader
's
URL
s represented as described abovepublic static final DependencyRequest getDependencyRequest(String classpathLikeString, List<RemoteRepository> remoteRepositories)
null
DependencyRequest
by parsing
the supplied classpath-like String
for Maven artifact
coordinates, and then invoking and returning the result of the
getDependencyRequest(Set, List)
method.
This method never returns null
.
Elements within the supplied classpathLikeString
are
separated by double occurrences of the platform-specific
classpath separator. For example, on Unix and Unix-derived
systems, a classpath-like string of the form com.foo:bar:1.0::com.fizz:buzz:1.0
will yield two elements:
com.foo:bar:1.0
and com.fizz:buzz:1.0
. On
Windows systems, a classpath-like string of the form com.foo:bar:1.0;;com.fizz:buzz:1.0
will yield two elements:
com.foo:bar:1.0
and com.fizz:buzz:1.0
.
classpathLikeString
- a classpath-like String
formatted as described above; may be null
remoteRepositories
- a List
of RemoteRepository
instances that will be forwarded on to the
getDependencyRequest(Set, List)
method; must not be
null
getDependencyRequest(Set, List)
methodNullPointerException
- if remoteRepositories
is
null
public static final DependencyRequest getDependencyRequest(Set<? extends Artifact> artifacts, List<RemoteRepository> remoteRepositories)
Set
of Artifact
s and a List
of
RemoteRepository
instances representing repositories from
which they might be resolved, creates and returns a DependencyRequest
for their resolution, using runtime scope.
This method never returns null
.
artifacts
- a Set
of Artifact
s to resolve;
may be null
remoteRepositories
- a List
of RemoteRepository
instances representing Maven repositories from
which the supplied Artifact
instances may be resolved;
must not be null
null
DependencyRequest
NullPointerException
- if remoteRepositories
is
null
getDependencyRequest(Set, String, List)
public static final DependencyRequest getDependencyRequest(Set<? extends Artifact> artifacts, String scope, List<RemoteRepository> remoteRepositories)
Set
of Artifact
s and a List
of
RemoteRepository
instances representing repositories from
which they might be resolved, creates and returns a DependencyRequest
for their resolution in the supplied scope.
This method never returns null
.
artifacts
- a Set
of Artifact
s to resolve;
may be null
scope
- the scope in which resolution should take place; may
be null
in which case JavaScopes.RUNTIME
will be
used instead; see JavaScopes
for commonly-used scopesremoteRepositories
- a List
of RemoteRepository
instances representing Maven repositories from
which the supplied Artifact
instances may be resolved;
must not be null
null
DependencyRequest
NullPointerException
- if remoteRepositories
is
null
JavaScopes
,
getDependencyRequest(CollectRequest)
public static final DependencyRequest getDependencyRequest(CollectRequest collectRequest)
null
DependencyRequest
suitable for
the supplied CollectRequest
.
This method never returns null
.
collectRequest
- a CollectRequest
describing
dependency collection; must not be null
DependencyRequest
; never null
NullPointerException
- if collectRequest
is
null
CollectRequest
,
DependencyRequest
,
MavenArtifactClassLoader(RepositorySystem,
RepositorySystemSession, DependencyRequest, ClassLoader,
URLStreamHandlerFactory)
public static final Collection<? extends URL> getUrls(RepositorySystem repositorySystem, RepositorySystemSession session, DependencyRequest dependencyRequest) throws DependencyResolutionException
Collection
of (file
) URL
s that
results from resolution of the dependencies described by the
supplied DependencyRequest
.
This method never returns null
.
repositorySystem
- the RepositorySystem
responsible
for resolving artifacts; must not be null
session
- the RepositorySystemSession
governing
certain aspects of the resolution process; must not be null
dependencyRequest
- the DependencyRequest
that
describes what artifacts should be resolved; must not be null
null
Collection
of distinct URL
s; a Set
is not part of the contract of this method
only because the URL.equals(Object)
method involves DNS
lookupsNullPointerException
- if any parameter is null
DependencyResolutionException
- if there was a problem
with dependency resolutionCopyright © 2019–2019, microBean™. All rights reserved.