A gradle plugin for handling the relocation of kotlin projects, fixing kotlin metadata and module files.
Stolen Inspired from the jetbrains exposed gradle plugin.
And also Spliterash/shadow-kotlin-relocate for some bug fixes.
First, add the xpdustry maven repository to plugin management in your settings.gradle.kts
file.
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://maven.xpdustry.com/releases") {
name = "xpdustry-releases"
mavenContent { releasesOnly() }
}
}
}
Then invoke the plugin after shadow in your build.gradle.kts
file.
plugins {
java
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.xpdustry.ksr") version "1.0.0"
}
Now, you can enjoy the additional kotlinRelocate
extension method to handle your kotlin libraries.
import com.xpdustry.ksr.kotlinRelocate
tasks.shadowJar {
// Popular java json library
relocate("com.google.gson", "shadow.gson")
// Very nice configuration library for Kotlin
kotlinRelocate("com.sksamuel.hoplite", "shadow.hoplite")
}
This plugin is designed for kotlin mindustry and minecraft mods/plugins using an un-relocated kotlin stdlib.
Also, for kotlin multiplatform projects, the relocation for optional expectation is not implemented (because I don't know how they work).
If you need help, you can talk to the maintainers on the Xpdustry Discord in the #support
channel.