Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

xpdustry/kotlin-shadow-relocator

Repository files navigation

kotlin-shadow-relocator

GitHub Workflow Status Discord Gradle Plugin Portal

Warning

Kotlin relocation is now supported by shadow since version 9.2.1.

In order to use it, remove KSR from your build scripts and replace kotlinRelocate calls with just relocate.

Thank @goooler for the excellent work he put into integrating KSR functionalities into shadow.

KSR is therefore deprecated and will be archived at the end of october 2025.

Description

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.

Usage

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() }
        }
    }
}

Limitations

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.

Support

If you need help, you can talk to the maintainers on the Xpdustry Discord in the #support channel.

About

A gradle plugin providing simple relocator that can handle kotlin metadata and modules.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors

Languages