Skip to content

Commit 77cde5b

Browse files
committed
Remove Arch Plugin and Shadow, clean up buildscript
- Disabled refmaps - Disabled common remapJar - Replaced shadow with directly including the common code + jij for jankson - Split off MinifyJsonPlugin from the data generator plugin
1 parent acb291a commit 77cde5b

File tree

8 files changed

+50
-95
lines changed

8 files changed

+50
-95
lines changed

build-logic/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ gradlePlugin {
2828
implementationClass = "juuxel.adorn.gradle.EmiDataGeneratorPlugin"
2929
}
3030

31+
register("adorn-minify-json") {
32+
id = "adorn-minify-json"
33+
implementationClass = "juuxel.adorn.gradle.MinifyJsonPlugin"
34+
}
35+
3136
register("adorn-service-inline") {
3237
id = "adorn-service-inline"
3338
implementationClass = "juuxel.adorn.gradle.ServiceInlinePlugin"

build-logic/src/main/java/juuxel/adorn/gradle/DataGeneratorPlugin.java

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package juuxel.adorn.gradle;
22

3-
import juuxel.adorn.gradle.action.MinifyJson;
43
import juuxel.adorn.gradle.datagen.DataGeneratorExtension;
54
import juuxel.adorn.gradle.datagen.DeleteDuplicates;
65
import juuxel.adorn.gradle.datagen.GenerateData;
@@ -37,8 +36,5 @@ public void apply(Project project) {
3736
main.getResources().srcDir(generatedResources);
3837
main.getResources().exclude(".cache");
3938
});
40-
project.afterEvaluate(p -> {
41-
p.getTasks().named("remapJar", task -> task.doLast(new MinifyJson()));
42-
});
4339
}
4440
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package juuxel.adorn.gradle;
2+
3+
import juuxel.adorn.gradle.action.MinifyJson;
4+
import org.gradle.api.Plugin;
5+
import org.gradle.api.Project;
6+
7+
public final class MinifyJsonPlugin implements Plugin<Project> {
8+
@Override
9+
public void apply(Project target) {
10+
target.getTasks().named("remapJar", task -> {
11+
task.doLast(new MinifyJson());
12+
});
13+
}
14+
}

build.gradle.kts

+25-48
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
21
import net.fabricmc.loom.api.LoomGradleExtensionAPI
32
import net.fabricmc.loom.task.RemapJarTask
43

@@ -9,17 +8,9 @@ plugins {
98
// See https://docs.gradle.org/current/userguide/base_plugin.html.
109
base
1110

12-
// Set up specific versions of the plugins we're using.
13-
// Note that of all these plugins, only the Architectury plugin needs to be applied.
14-
id("architectury-plugin") version "3.4.+"
11+
// Set up a specific version of Loom. There's no code in the root project,
12+
// so we don't need to apply it here.
1513
id("dev.architectury.loom") version "1.7.+" apply false
16-
17-
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
18-
}
19-
20-
// Set the Minecraft version for Architectury.
21-
architectury {
22-
minecraft = project.property("minecraft-version").toString()
2314
}
2415

2516
// Set up basic Maven artifact metadata, including the project version
@@ -55,23 +46,23 @@ tasks {
5546
register("classes")
5647
}
5748

58-
// Do the shared set up for the Minecraft subprojects.
49+
// Do the shared setup for the Minecraft subprojects.
5950
subprojects {
6051
apply(plugin = "dev.architectury.loom")
61-
apply(plugin = "architectury-plugin")
52+
53+
// Find the loom extension. Since it's not applied to the root project, we can't access it directly
54+
// by name in this file.
55+
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
56+
loom.mixin {
57+
useLegacyMixinAp.set(false)
58+
}
6259

6360
// Set Java version.
6461
extensions.configure<JavaPluginExtension> {
6562
sourceCompatibility = JavaVersion.VERSION_21
6663
targetCompatibility = JavaVersion.VERSION_21
6764
}
6865

69-
architectury {
70-
// Disable Architectury's runtime transformer
71-
// since we don't use it.
72-
compileOnly()
73-
}
74-
7566
// Copy the artifact metadata from the root project.
7667
group = rootProject.group
7768
version = rootProject.version
@@ -100,6 +91,12 @@ subprojects {
10091
}
10192
}
10293

94+
// For REI.
95+
maven {
96+
name = "shedaniel"
97+
url = uri("https://maven.shedaniel.me")
98+
}
99+
103100
// TerraformersMC maven for Mod Menu and EMI.
104101
maven {
105102
name = "TerraformersMC"
@@ -128,10 +125,6 @@ subprojects {
128125
// and so the Kotlin accessor method for it isn't generated for this file.
129126
"minecraft"("net.minecraft:minecraft:${rootProject.property("minecraft-version")}")
130127

131-
// Find the loom extension. Since it's not applied to the root project, we can't access it directly
132-
// by name in this file.
133-
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
134-
135128
// Set up the layered mappings with Yarn and my Menu mappings.
136129
// The average modder would have "mappings"("net.fabricmc:yarn:...") or "mappings"(loom.officialMojangMappings()).
137130
"mappings"(loom.layered {
@@ -167,50 +160,34 @@ subprojects {
167160
// Set up "platform" subprojects (non-common subprojects).
168161
subprojects {
169162
if (path != ":common") {
170-
// Apply the shadow plugin which lets us include contents
171-
// of any libraries in our mod jars. Architectury uses it
172-
// for bundling the common mod code in the platform jars.
173-
apply(plugin = "com.github.johnrengelman.shadow")
163+
fun Project.sourceSets() = extensions.getByName<SourceSetContainer>("sourceSets")
174164

175165
// Set a different run directory for the server run config,
176166
// so it won't override client logs/config (or vice versa).
177167
extensions.configure<LoomGradleExtensionAPI> {
178-
runConfigs.getByName("server") {
168+
// Generate IDE run configs for each run config.
169+
runs.configureEach {
170+
isIdeConfigGenerated = true
171+
}
172+
173+
// Set a different run directory for the server so the log and config files don't conflict.
174+
runs.named("server") {
179175
runDir = "run/server"
180176
}
181177

182178
// "main" matches the default NeoForge mod's name
183179
with(mods.maybeCreate("main")) {
184-
fun Project.sourceSets() = extensions.getByName<SourceSetContainer>("sourceSets")
185180
sourceSet(sourceSets().getByName("main"))
186181
sourceSet(project(":common").sourceSets().getByName("main"))
187182
}
188183
}
189184

190-
// Define the "bundle" configuration which will be included in the shadow jar.
191-
val bundle by configurations.creating {
192-
// This configuration is only meant to be resolved to its files but not published in
193-
// any way, so we set canBeConsumed = false and canBeResolved = true.
194-
// See https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:resolvable-consumable-configs.
195-
isCanBeConsumed = false
196-
isCanBeResolved = true
197-
}
198-
199185
tasks {
200186
"jar"(Jar::class) {
201-
archiveClassifier.set("dev-slim")
202-
}
203-
204-
"shadowJar"(ShadowJar::class) {
205-
archiveClassifier.set("dev-shadow")
206-
// Include our bundle configuration in the shadow jar.
207-
configurations = listOf(bundle)
187+
from(project(":common").sourceSets().named("main").map { it.output })
208188
}
209189

210190
"remapJar"(RemapJarTask::class) {
211-
dependsOn("shadowJar")
212-
// Replace the remap jar task's input with the shadow jar containing the common classes.
213-
inputFile.set(named<ShadowJar>("shadowJar").flatMap { it.archiveFile })
214191
// The project name will be "fabric" or "neoforge", so this will become the classifier/suffix
215192
// for the jar. For example: Adorn-3.4.0-fabric.jar
216193
archiveClassifier.set(project.name)

common/build.gradle.kts

-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ plugins {
22
id("adorn-data-generator")
33
}
44

5-
architectury {
6-
// Set up Architectury for the common project.
7-
// This sets up the transformations (@ExpectPlatform etc.) we need for production environments.
8-
common(
9-
"fabric",
10-
"neoforge",
11-
)
12-
}
13-
145
loom {
156
accessWidenerPath.set(file("src/main/resources/adorn.accesswidener"))
167
}

common/gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Skip remapping jars for common code. We don't use them, and it slows down the build.
2+
fabric.loom.dontRemap = true

fabric/build.gradle.kts

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
plugins {
22
id("adorn-data-generator")
33
id("adorn-data-generator.emi")
4+
id("adorn-minify-json")
45
id("adorn-service-inline")
56
}
67

7-
architectury {
8-
// Create the IDE launch configurations for this subproject.
9-
platformSetupLoomIde()
10-
// Set up Architectury for Fabric.
11-
fabric()
12-
}
13-
148
// The files below are for using the access widener for the common project.
159
// We need to copy the file from common resources to fabric resource
1610
// for Fabric Loader to find it and not crash.
@@ -59,19 +53,14 @@ dependencies {
5953
implementation(project(":common", configuration = "namedElements")) {
6054
isTransitive = false
6155
}
62-
// Bundle the transformed version of the common project in the mod.
63-
// The transformed version includes things like fixed refmaps.
64-
bundle(project(path = ":common", configuration = "transformProductionFabric")) {
65-
isTransitive = false
66-
}
6756

6857
// Standard Fabric mod setup.
6958
modImplementation(libs.fabric.loader)
7059
modImplementation(libs.fabric.api)
7160

7261
// Bundle Jankson in the mod and use it as a regular "implementation" library.
7362
implementation(libs.jankson)
74-
bundle(libs.jankson)
63+
include(libs.jankson)
7564

7665
// Mod compat
7766
modCompileOnly(libs.towelette)
@@ -84,10 +73,6 @@ dependencies {
8473
}
8574

8675
tasks {
87-
shadowJar {
88-
relocate("blue.endless.jankson", "juuxel.adorn.relocated.jankson")
89-
}
90-
9176
processResources {
9277
// Mark that this task depends on the project version,
9378
// and should reset when the project version changes.

forge/build.gradle.kts

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
plugins {
22
id("adorn-data-generator")
33
id("adorn-data-generator.emi")
4+
id("adorn-minify-json")
45
id("adorn-service-inline")
56
}
67

7-
architectury {
8-
// Create the IDE launch configurations for this subproject.
9-
platformSetupLoomIde()
10-
// Set up Architectury for NeoForge.
11-
neoForge()
12-
}
13-
148
loom {
159
// Make the Forge project use the common access widener.
1610
accessWidenerPath.set(project(":common").file("src/main/resources/adorn.accesswidener"))
@@ -35,14 +29,9 @@ dependencies {
3529
implementation(project(":common", configuration = "namedElements")) {
3630
isTransitive = false
3731
}
38-
// Bundle the transformed version of the common project in the mod.
39-
// The transformed version includes things like fixed refmaps.
40-
bundle(project(path = ":common", configuration = "transformProductionNeoForge")) {
41-
isTransitive = false
42-
}
4332

4433
// Bundle Jankson in the mod.
45-
bundle(libs.jankson)
34+
include(libs.jankson)
4635
// Use Jankson as a library. Note that on Forge, regular non-mod libraries have to be declared
4736
// using forgeRuntimeLibrary as Forge reads the runtime classpath from a separately generated file.
4837
// In ForgeGradle projects, you might see a custom "library" configuration used for this.
@@ -54,10 +43,6 @@ dependencies {
5443
}
5544

5645
tasks {
57-
shadowJar {
58-
relocate("blue.endless.jankson", "juuxel.adorn.relocated.jankson")
59-
}
60-
6146
remapJar {
6247
// Convert the access widener to a NeoForge access transformer.
6348
atAccessWideners.add("adorn.accesswidener")

0 commit comments

Comments
 (0)