This Project contains all Gradle plugins made for redicloud.
The Library Loader's purpose is to reduce the .jar size. This is made possible by splitting the process in two.
The Gradle plugin configures everything and grabs the dependencies from there.
It works by overriding the main class and inserting agents, which will be able by using the instrumentation
to insert Jars.
You can add the plugin by using this code:
// build.gradle.kts
plugins {
id("dev.redicloud.libloader") version ("1.7.0")
}
repositories {
maven("https://repo.redicloud.dev/releases/")
}
// build.gradle.kts
import dev.redicloud.libloader.plugin.LibraryLoader.LibraryLoaderConfig
//...
the(LibraryLoaderConfig::class).apply {
this.mainClass.set("dev.redicloud.testing.Main") // Not mandatory when using non-standalone Jars, see chapter Bootloader
this.libraryFolder.set(".libs/") // Default Value
this.configurationName.set("runtimeClasspath") // Default Value, configuration to use for dependencies
}
// build.gradle.kts
dependencies {
shade("x.y.z:a:b.c.d") // Instead of dynamically loading, it will be put in the Jar
}
The Bootloader is shaded into the Jar and gets the the dependencies using Gson, JSoup and internal JSONs.
After initializing, when used in a standalone Jar, the main method given will be executed. No further action other than adding it to the configuration of the Plugin needed.
Using the URLClassLoaderJarLoader
you are able to load dependencies for your plugins.
Example Spigot:
class Plugin: JavaPlugin() {
override fun onLoad() {
Bootstrap().apply(URLClassLoaderJarLoader(this::class.java.classLoader as URLClassLoader))
}
}
Example Velocity:
@Plugin(...)
class Plugin @Inject constructor(private val proxy: ProxyServer) : PluginContainer {
@Subscribe
fun init(e: ProxyInitializeEvent) {
Bootstrap().apply(URLClassLoaderJarLoader(this::class.java.classLoader as URLClassLoader))
}
}