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 Artifacts 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 Artifacts 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) URLs 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 URLs. |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstancedefineClass, defineClassclearAssertionStatus, 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, setSignerspublic MavenArtifactClassLoader(RepositorySystem repositorySystem, RepositorySystemSession session, DependencyRequest dependencyRequest) throws DependencyResolutionException
MavenArtifactClassLoader.repositorySystem - the RepositorySystem responsible
for resolving artifacts; must not be nullsession - the RepositorySystemSession governing
certain aspects of the resolution process; must not be nulldependencyRequest - the DependencyRequest that
describes what artifacts should be resolved; must not be nullNullPointerException - if a parameter that must not be
null is discovered to be nullDependencyResolutionException - 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 nullsession - the RepositorySystemSession governing
certain aspects of the resolution process; must not be nulldependencyRequest - the DependencyRequest that
describes what artifacts should be resolved; must not be nullparentClassLoader - the ClassLoader that will
parent this one; may be
nullNullPointerException - if a parameter that must not be
null is discovered to be nullDependencyResolutionException - 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 nullsession - the RepositorySystemSession governing
certain aspects of the resolution process; must not be nulldependencyRequest - the DependencyRequest that
describes what artifacts should be resolved; must not be nullparentClassLoader - the ClassLoader that will
parent this one; may be
nullurlStreamHandlerFactory - the URLStreamHandlerFactory to create URLStreamHandlers for
the URLs URLs 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 nullDependencyResolutionException - 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 URLs.
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 URLs 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
URLs 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 nullremoteRepositories - a List of RemoteRepository instances that will be forwarded on to the
getDependencyRequest(Set, List) method; must not be
nullgetDependencyRequest(Set, List) methodNullPointerException - if remoteRepositories is
nullpublic static final DependencyRequest getDependencyRequest(Set<? extends Artifact> artifacts, List<RemoteRepository> remoteRepositories)
Set of Artifacts 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 Artifacts to resolve;
may be nullremoteRepositories - a List of RemoteRepository instances representing Maven repositories from
which the supplied Artifact instances may be resolved;
must not be nullnull DependencyRequestNullPointerException - if remoteRepositories is
nullgetDependencyRequest(Set, String, List)public static final DependencyRequest getDependencyRequest(Set<? extends Artifact> artifacts, String scope, List<RemoteRepository> remoteRepositories)
Set of Artifacts 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 Artifacts to resolve;
may be nullscope - 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 nullnull DependencyRequestNullPointerException - if remoteRepositories is
nullJavaScopes,
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 nullDependencyRequest; never nullNullPointerException - if collectRequest is
nullCollectRequest,
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) URLs 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 nullsession - the RepositorySystemSession governing
certain aspects of the resolution process; must not be nulldependencyRequest - the DependencyRequest that
describes what artifacts should be resolved; must not be nullnull Collection of distinct URLs; 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 nullDependencyResolutionException - if there was a problem
with dependency resolutionCopyright © 2019–2019, microBean™. All rights reserved.