From 5368821c12af74c3915df32a3b87976b0564fe22 Mon Sep 17 00:00:00 2001 From: Erdragh Date: Wed, 3 Jan 2024 10:41:42 +0100 Subject: [PATCH] Make Exposed and SQLite relocation work --- build.gradle.kts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 19effd1..321946d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer import dev.architectury.plugin.ArchitectPluginExtension import net.fabricmc.loom.api.LoomGradleExtensionAPI import net.fabricmc.loom.task.RemapJarTask @@ -181,12 +182,21 @@ subprojects { archiveClassifier.set("dev-shadow") configurations = listOf(shadowCommon) + // 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) + // Relocating Exposed and the sqlite driver 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") + relocate("org.sqlite", "dev.erdragh.shadowed.org.sqlite") + + // Transforms the reference to point to the relocated sqlite driver (see: https://github.com/xerial/sqlite-jdbc/issues/145) + transform(AppendingTransformer::class.java) { + resource = "META-INF/services/java.sql.Driver" + } exclude(".cache/**") //Remove datagen cache from jar. exclude("**/astralbot/datagen/**") //Remove data gen code from jar.