From 2bb816674403d3d989dc1dba5db40e85d9a96649 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:18:19 +0200 Subject: [PATCH] Set up Shadow for bundling DFU --- build.gradle | 31 +++++++++++++++++++++++-------- gradle/libs.versions.toml | 4 ++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 00164044..31a17eb0 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,7 @@ plugins { alias(libs.plugins.kotlin) apply false // Delay this so we can perform magic 🪄 first. alias(libs.plugins.spotless) alias(libs.plugins.retry) + alias(libs.plugins.shadow) } /** @@ -91,6 +92,13 @@ configurations { compileClasspath.extendsFrom bootstrap runtimeClasspath.extendsFrom bootstrap testRuntimeClasspath.extendsFrom bootstrap + bundled { + transitive = false + } + compileClasspath.extendsFrom bundled + runtimeClasspath.extendsFrom bundled + testCompileClasspath.extendsFrom bundled + testRuntimeClasspath.extendsFrom bundled } configurations.all { @@ -187,7 +195,7 @@ dependencies { implementation libs.mcinjector implementation libs.opencsv implementation libs.forge.diffpatch - implementation 'com.mojang:datafixerupper:6.0.8' + bundled libs.datafixerupper // Forge mods.toml parsing implementation libs.night.config.toml @@ -223,6 +231,13 @@ jar { from sourceSets.cfr.output.classesDirs from sourceSets.fernflower.output.classesDirs from sourceSets.vineflower.output.classesDirs + archiveClassifier = "slim" +} + +shadowJar { + archiveClassifier = "" + configurations = [project.configurations.bundled] + relocate 'com.mojang', 'dev.architectury.loom.relocated.com.mojang' } base { @@ -334,14 +349,14 @@ publishing { publications { if (isSnapshot) return - // Also publish a snapshot so people can use the latest version if they wish - snapshot(MavenPublication) { publication -> - groupId project.group - artifactId project.base.archivesName.get() - version baseVersion + '-SNAPSHOT' + // Also publish a snapshot so people can use the latest version if they wish + snapshot(MavenPublication) { publication -> + groupId project.group + artifactId project.base.archivesName.get() + version baseVersion + '-SNAPSHOT' - from components.java - } + shadow.component(publication) + } // Manually crate the plugin marker for snapshot versions snapshotPlugin(MavenPublication) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 40cda011..dd9fe50d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,6 +20,7 @@ test-retry = "1.5.4" checkstyle = "10.12.2" codenarc = "3.3.0" jacoco = "0.8.10" +shadow = "8.1.1" # Forge libraries forge-installer-tools = "1.2.0" @@ -28,6 +29,7 @@ mcinjector = "3.8.0" opencsv = "5.4" forge-diffpatch = "2.0.7" night-config = "3.6.6" +datafixerupper = "6.0.8" [libraries] # Loom compile libraries @@ -60,11 +62,13 @@ mcinjector = { module = "de.oceanlabs.mcp:mcinjector", version.ref = "mcinjector opencsv = { module = "com.opencsv:opencsv", version.ref = "opencsv" } forge-diffpatch = { module = "net.minecraftforge:DiffPatch", version.ref = "forge-diffpatch" } night-config-toml = { module = "com.electronwill.night-config:toml", version.ref = "night-config" } +datafixerupper = { module = "com.mojang:datafixerupper", version.ref = "datafixerupper" } [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } retry = { id = "org.gradle.test-retry", version.ref = "test-retry" } +shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } [bundles] asm = ["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"]