Class MavenLibraryResolver
java.lang.Object
io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver
- All Implemented Interfaces:
ClassPathLibrary
The maven library resolver acts as a resolver for yet to be resolved jar libraries that may be pulled from a
remote maven repository.
Plugins may create and configure a MavenLibraryResolver
by creating a new one and registering both
a dependency artifact that should be resolved to a library at runtime and the repository it is found in.
An example of this would be the inclusion of the jooq library for typesafe SQL queries:
MavenLibraryResolver resolver = new MavenLibraryResolver();
resolver.addDependency(new Dependency(new DefaultArtifact("org.jooq:jooq:3.17.7"), null));
resolver.addRepository(new RemoteRepository.Builder(
"central", "default", "https://repo1.maven.org/maven2/"
).build());
Plugins may create and register a MavenLibraryResolver
after configuring it.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDependency
(Dependency dependency) Adds the provided dependency to the library resolver.void
addRepository
(RemoteRepository remoteRepository) Adds the provided repository to the library resolver.void
register
(LibraryStore store) Resolves the provided dependencies and adds them to the library store.
-
Constructor Details
-
MavenLibraryResolver
public MavenLibraryResolver()Creates a new maven library resolver instance.The created instance will use the servers
libraries
folder to cache fetched libraries in. Notably, the resolver is created without any repository, not even maven central. It is hence crucial that plugins which aim to use this api register all required repositories before submitting theMavenLibraryResolver
to thePluginClasspathBuilder
.
-
-
Method Details
-
addDependency
Adds the provided dependency to the library resolver. The artifact from the first valid repository matching the passed dependency will be chosen.- Parameters:
dependency
- the definition of the dependency the maven library resolver should resolve when running- See Also:
-
addRepository
Adds the provided repository to the library resolver. The order in which these are added does matter, as dependency resolving will start at the first added repository.- Parameters:
remoteRepository
- the configuration that defines the maven repository this library resolver should fetch dependencies from
-
register
Resolves the provided dependencies and adds them to the library store.- Specified by:
register
in interfaceClassPathLibrary
- Parameters:
store
- the library store the then resolved and downloaded dependencies are registered into- Throws:
LibraryLoadingException
- if resolving a dependency failed
-