Skip to content

Commit

Permalink
Simplify shadowJar configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed May 30, 2024
1 parent 3e0c814 commit 38dad35
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 43 deletions.
45 changes: 45 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.utils.extendsFrom
import java.nio.charset.StandardCharsets
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -112,6 +113,10 @@ subprojects {
"org.jetbrains.exposed:exposed-dao:$exposedVersion",
"org.jetbrains.exposed:exposed-jdbc:$exposedVersion",
).forEach {
implementation(it) {
exclude(module = "opus-java")
exclude(group = "org.slf4j")
}
runtimeLib(it) {
exclude(module = "opus-java")
exclude(group = "org.slf4j")
Expand All @@ -125,6 +130,7 @@ subprojects {
// on JDA and Exposed, but is already provided by the
// respective Kotlin implementation of the mod loaders
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
// Minecraft already ships with a logging system
exclude(group = "org.slf4j")
}
Expand Down Expand Up @@ -197,9 +203,48 @@ subprojects {
}

if (!isCommon) {
apply(plugin = "io.github.goooler.shadow")

dependencies {
implementation(project(":common"))
}

tasks.named<ShadowJar>("shadowJar") {
// The shadowBotDep configuration was explicitly made to be shaded in, this is where that happens
configurations.clear()
configurations = listOf(shadowBotDep)

// This transforms the service files to make relocated Exposed work (see: https://github.com/JetBrains/Exposed/issues/1353)
mergeServiceFiles()

// Forge restricts loading certain classes for security reasons.
// Luckily, shadow can relocate them to a different package.
relocate("org.apache.commons.collections4", "dev.erdragh.shadowed.org.apache.commons.collections4")

// Relocating Exposed somewhere different so other mods not doing that don't run into issues (e.g. Ledger)
relocate("org.jetbrains.exposed", "dev.erdragh.shadowed.org.jetbrains.exposed")

// Relocating jackson to prevent incompatibilities with other mods also bundling it (e.g. GroovyModLoader on Forge)
relocate("com.fasterxml.jackson", "dev.erdragh.shadowed.com.fasterxml.jackson")

// relocate discord interaction stuff to maybe allow other discord integrations mods to work
relocate("club.minnced.discord", "dev.erdragh.shadowed.club.minnced.discord")
relocate("net.dv8tion.jda", "dev.erdragh.shadowed.net.dv8tion.jda")

// relocate dependencies of discord stuff
relocate("okhttp3", "dev.erdragh.shadowed.okhttp3")
relocate("okio", "dev.erdragh.shadowed.okio")
relocate("gnu.trove", "dev.erdragh.shadowed.gnu.trove")
relocate("com.iwebpp.crypto", "dev.erdragh.shadowed.com.iwebpp.crypto")
relocate("com.neovisionaries.ws", "dev.erdragh.shadowed.com.neovisionaries.ws")
relocate("org.json", "dev.erdragh.shadowed.org.json")
relocate("net.bytebuddy", "dev.erdragh.net.bytebuddy")

exclude("**/org/slf4j/**")

exclude("**/org/jetbrains/annotations/*")
exclude("**/org/intellij/**")
}
}

// Disables Gradle's custom module metadata from being published to maven. The
Expand Down
20 changes: 0 additions & 20 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,6 @@ tasks {

shadowJar {
archiveClassifier.set("dev-shadow")

configurations = listOf(shadowBotDep)

// This transforms the service files to make relocated Exposed work (see: https://github.com/JetBrains/Exposed/issues/1353)
mergeServiceFiles()

// Relocating Exposed somewhere different so other mods not doing that don't run into issues (e.g. Ledger)
relocate("org.jetbrains.exposed", "dev.erdragh.shadowed.org.jetbrains.exposed")

// Relocating jackson to prevent incompatibilities with other mods also bundling it (e.g. GroovyModLoader on Forge)
relocate("com.fasterxml.jackson", "dev.erdragh.shadowed.com.fasterxml.jackson")

exclude(".cache/**") //Remove datagen cache from jar.
exclude("**/astralbot/datagen/**") //Remove data gen code from jar.
exclude("**/org/slf4j/**")

exclude("kotlinx/**")
exclude("_COROUTINE/**")
exclude("**/org/jetbrains/annotations/*")
exclude("**/org/intellij/**")
}

remapJar {
Expand Down
23 changes: 0 additions & 23 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,6 @@ tasks {

shadowJar {
archiveClassifier = null
configurations = listOf(shadowBotDep)

// This transforms the service files to make relocated Exposed work (see: https://github.com/JetBrains/Exposed/issues/1353)
mergeServiceFiles()

// Forge restricts loading certain classes for security reasons.
// Luckily, shadow can relocate them to a different package.
relocate("org.apache.commons.collections4", "dev.erdragh.shadowed.org.apache.commons.collections4")

// Relocating Exposed somewhere different so other mods not doing that don't run into issues (e.g. Ledger)
relocate("org.jetbrains.exposed", "dev.erdragh.shadowed.org.jetbrains.exposed")

// Relocating jackson to prevent incompatibilities with other mods also bundling it (e.g. GroovyModLoader on Forge)
relocate("com.fasterxml.jackson", "dev.erdragh.shadowed.com.fasterxml.jackson")

exclude(".cache/**") //Remove datagen cache from jar.
exclude("**/astralbot/datagen/**") //Remove data gen code from jar.
exclude("**/org/slf4j/**")

exclude("kotlinx/**")
exclude("_COROUTINE/**")
exclude("**/org/jetbrains/annotations/*")
exclude("**/org/intellij/**")
}

jarJar.configure {
Expand Down

0 comments on commit 38dad35

Please sign in to comment.