Package net.bytebuddy.build.maven
Class ClassLoaderResolver
java.lang.Object
net.bytebuddy.build.maven.ClassLoaderResolver
- All Implemented Interfaces:
Closeable
,AutoCloseable
A resolver that transforms a Maven coordinate into a class loader that can view the dependencies implied by this coordinate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<MavenCoordinate,
ClassLoader> A mapping of Maven coordinates to already existing class loaders.private final org.apache.maven.plugin.logging.Log
The Maven log dispatcher.private final List<org.eclipse.aether.repository.RemoteRepository>
A list of remote repositories available.private final org.eclipse.aether.RepositorySystem
The repository system to use.private final org.eclipse.aether.RepositorySystemSession
The repository system session to use. -
Constructor Summary
ConstructorsConstructorDescriptionClassLoaderResolver
(org.apache.maven.plugin.logging.Log log, org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) Creates a new class loader resolver. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
private ClassLoader
doResolve
(MavenCoordinate mavenCoordinate) Resolves a Maven coordinate to a class loader that can load all of the coordinates classes.resolve
(MavenCoordinate mavenCoordinate) Resolves a Maven coordinate to a class loader that can load all of the coordinates classes.
-
Field Details
-
log
private final org.apache.maven.plugin.logging.Log logThe Maven log dispatcher. -
repositorySystem
private final org.eclipse.aether.RepositorySystem repositorySystemThe repository system to use. -
repositorySystemSession
private final org.eclipse.aether.RepositorySystemSession repositorySystemSessionThe repository system session to use. -
remoteRepositories
A list of remote repositories available. -
classLoaders
A mapping of Maven coordinates to already existing class loaders.
-
-
Constructor Details
-
ClassLoaderResolver
public ClassLoaderResolver(org.apache.maven.plugin.logging.Log log, org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) Creates a new class loader resolver.- Parameters:
log
- The Maven log dispatcher.repositorySystem
- The repository system to use.repositorySystemSession
- The repository system session to use.remoteRepositories
- A list of remote repositories available.
-
-
Method Details
-
resolve
public ClassLoader resolve(MavenCoordinate mavenCoordinate) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException Resolves a Maven coordinate to a class loader that can load all of the coordinates classes. If a Maven coordinate was resolved previously, the previously created class loader is returned.- Parameters:
mavenCoordinate
- The Maven coordinate to resolve.- Returns:
- A class loader that references all of the class loader's dependencies and which is a child of this class's class loader.
- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the user configuration results in an error.org.apache.maven.plugin.MojoFailureException
- If the plugin application raises an error.
-
doResolve
private ClassLoader doResolve(MavenCoordinate mavenCoordinate) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException Resolves a Maven coordinate to a class loader that can load all of the coordinates classes.- Parameters:
mavenCoordinate
- The Maven coordinate to resolve.- Returns:
- A class loader that references all of the class loader's dependencies and which is a child of this class's class loader.
- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the user configuration results in an error.org.apache.maven.plugin.MojoFailureException
- If the plugin application raises an error.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-