Add ShadowJar plugin for shaded build

Configure package relocation to avoid dependency conflicts.
Update build process to produce minimized ShadowJar artifacts and disable default jar task.
This commit is contained in:
akastijn 2025-06-29 02:17:09 +02:00
parent d4359bf480
commit 2ef5bd8ba2

View File

@ -1,11 +1,22 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("java")
id("com.gradleup.shadow") version "9.0.0-beta17"
}
group = "com.alttd.webinterface"
version = "1.0-SNAPSHOT"
description = "WebInterface"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
repositories {
mavenCentral()
maven("https://nexus.velocitypowered.com/repository/maven-public/")
@ -25,3 +36,25 @@ dependencies {
tasks.test {
useJUnitPlatform()
}
tasks.withType<ShadowJar> {
// Relocate packages to avoid conflicts with other plugins
relocate("io.javalin", "com.alttd.webinterface.shaded.io.javalin")
relocate("org.slf4j", "com.alttd.webinterface.shaded.org.slf4j")
relocate("kotlin", "com.alttd.webinterface.shaded.kotlin")
relocate("org.eclipse.jetty", "com.alttd.webinterface.shaded.org.eclipse.jetty")
minimize()
}
tasks.build {
dependsOn(tasks.shadowJar)
}
tasks.jar {
enabled = false
}
artifacts {
archives(tasks.shadowJar)
}