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.
Simply add the plugin after shadow in your build.gradle.kts
file.
plugins {
java
id("com.gradleup.shadow") version "$VERSION"
id("com.xpdustry.kotlin-shadow-relocator") version "$VERSION"
}
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")
}
If you wish to use snapshots, add our snapshot repository to plugin management in your settings.gradle.kts
file.
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://maven.xpdustry.com/snapshots") {
name = "xpdustry-snapshots"
mavenContent { snapshotsOnly() }
}
}
}
This plugin was designed for kotlin mindustry and minecraft mods/plugins using an un-relocated kotlin stdlib.
I can't guarantee that it will work with other kinds of project.
Also, for kotlin multiplatform projects, the relocation for optional expectation is not implemented (because I don't know how they work).
If you are familiar with asm or kotlin multiplatform internals, feel free to open a PR to help address the issues.
If you need help, you can talk to the maintainers on the Xpdustry Discord in the #support
channel.