Class LibraryLoaderUtil
This class provides methods to load libraries from Maven repositories, with support for relocation and isolation of the loaded libraries.
-
Constructor Summary
ConstructorsConstructorDescriptionLibraryLoaderUtil(Graves plugin) Constructs a new LibraryLoaderUtil instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidloadLibrary(String groupID, String artifactID, String version) Loads a library using the given group ID, artifact ID, and version.voidloadLibrary(String groupID, String artifactID, String version, boolean isIsolated) Loads a library with the specified group ID, artifact ID, version, and isolation flag.voidloadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated) Loads a library with relocation and isolation settings.voidloadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, boolean resolveTransitiveDependencies) Loads a library with relocation, isolation, and transitive dependency settings.voidloadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL) Loads a library with relocation, isolation, and custom repository URL.voidloadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL, boolean resolveTransitiveDependencies) Loads a library with relocation, isolation, custom repository URL, and transitive dependency settings.voidloadLibrary(String groupID, String artifactID, String version, String ID, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL, boolean resolveTransitiveDependencies) Loads a library into the runtime using the BukkitLibraryManager.
-
Constructor Details
-
LibraryLoaderUtil
Constructs a new LibraryLoaderUtil instance.- Parameters:
plugin- The plugin instance to associate with the library manager.
-
-
Method Details
-
loadLibrary
Loads a library using the given group ID, artifact ID, and version.Uses default values: no relocation, no loader ID, non-isolated, no custom repository URL, and resolves transitive dependencies.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.
-
loadLibrary
Loads a library with the specified group ID, artifact ID, version, and isolation flag.Uses default values: no relocation, no loader ID, no custom repository URL, and resolves transitive dependencies.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.isIsolated- (Required) Whether the library should be loaded in an isolated class loader.
-
loadLibrary
public void loadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated) Loads a library with relocation and isolation settings.Uses default values: no loader ID, no custom repository URL, and resolves transitive dependencies.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.relocatePattern- (Optional) Original package pattern to relocate (requires relocated pattern).relocateRelocatedPattern- (Optional) Target package pattern for relocation (requires original pattern).isIsolated- (Required) Whether the library should be loaded in an isolated class loader.
-
loadLibrary
public void loadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, boolean resolveTransitiveDependencies) Loads a library with relocation, isolation, and transitive dependency settings.Uses default values: no loader ID, no custom repository URL.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.relocatePattern- (Optional) Original package pattern to relocate (requires relocated pattern).relocateRelocatedPattern- (Optional) Target package pattern for relocation (requires original pattern).isIsolated- (Required) Whether the library should be loaded in an isolated class loader.resolveTransitiveDependencies- (Required) Whether to resolve transitive dependencies.
-
loadLibrary
public void loadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL) Loads a library with relocation, isolation, and custom repository URL.Uses default values: no loader ID, resolves transitive dependencies.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.relocatePattern- (Optional) Original package pattern to relocate (requires relocated pattern).relocateRelocatedPattern- (Optional) Target package pattern for relocation (requires original pattern).isIsolated- (Required) Whether the library should be loaded in an isolated class loader.libraryURL- (Optional) Custom repository URL; if null, defaults are used.
-
loadLibrary
public void loadLibrary(String groupID, String artifactID, String version, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL, boolean resolveTransitiveDependencies) Loads a library with relocation, isolation, custom repository URL, and transitive dependency settings.Uses default values: no loader ID.
- Parameters:
groupID- (Required) Maven group ID of the library.artifactID- (Required) Maven artifact ID of the library.version- (Required) Version of the library.relocatePattern- (Optional) Original package pattern to relocate (requires relocated pattern).relocateRelocatedPattern- (Optional) Target package pattern for relocation (requires original pattern).isIsolated- (Required) Whether the library should be loaded in an isolated class loader.libraryURL- (Optional) Custom repository URL; if null, defaults are used.resolveTransitiveDependencies- (Required) Whether to resolve transitive dependencies.
-
loadLibrary
public void loadLibrary(String groupID, String artifactID, String version, String ID, String relocatePattern, String relocateRelocatedPattern, boolean isIsolated, String libraryURL, boolean resolveTransitiveDependencies) Loads a library into the runtime using the BukkitLibraryManager.Required:
groupID,artifactID,version,isIsolated,resolveTransitiveDependencies.
Optional:ID,relocatePattern+relocateRelocatedPattern(must be provided together),libraryURL.If
libraryURLis null or blank, common repositories (Maven Central, Sonatype, JCenter, JitPack) are registered. If relocation is requested, both patterns must be non-blank. WhenisIsolatedis true andIDis blank, a stable loaderId ofartifactID + "-isolated"is used.- Parameters:
groupID- (Required) Maven group ID (use "{}" as dot placeholders; replaced with "." in logs/messages only).artifactID- (Required) Maven artifact ID.version- (Required) Library version to resolve.ID- (Optional) Loader ID for namespacing (recommended when isolated).relocatePattern- (Optional) Original package pattern to relocate; requiresrelocateRelocatedPattern.relocateRelocatedPattern- (Optional) Target package pattern for relocation; requiresrelocatePattern.isIsolated- (Required) Whether to load the library in an isolated class loader.libraryURL- (Optional) Custom repository URL to resolve from; if blank, defaults are used.resolveTransitiveDependencies- (Required) Whether to resolve transitive dependencies.- Throws:
IllegalArgumentException- if any required parameter is null/blank, or only one relocation pattern is provided.
-