1
- import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2
1
import net.fabricmc.loom.api.LoomGradleExtensionAPI
3
2
import net.fabricmc.loom.task.RemapJarTask
4
3
@@ -9,17 +8,9 @@ plugins {
9
8
// See https://docs.gradle.org/current/userguide/base_plugin.html.
10
9
base
11
10
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.
15
13
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()
23
14
}
24
15
25
16
// Set up basic Maven artifact metadata, including the project version
@@ -55,23 +46,23 @@ tasks {
55
46
register(" classes" )
56
47
}
57
48
58
- // Do the shared set up for the Minecraft subprojects.
49
+ // Do the shared setup for the Minecraft subprojects.
59
50
subprojects {
60
51
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
+ }
62
59
63
60
// Set Java version.
64
61
extensions.configure<JavaPluginExtension > {
65
62
sourceCompatibility = JavaVersion .VERSION_21
66
63
targetCompatibility = JavaVersion .VERSION_21
67
64
}
68
65
69
- architectury {
70
- // Disable Architectury's runtime transformer
71
- // since we don't use it.
72
- compileOnly()
73
- }
74
-
75
66
// Copy the artifact metadata from the root project.
76
67
group = rootProject.group
77
68
version = rootProject.version
@@ -100,6 +91,12 @@ subprojects {
100
91
}
101
92
}
102
93
94
+ // For REI.
95
+ maven {
96
+ name = " shedaniel"
97
+ url = uri(" https://maven.shedaniel.me" )
98
+ }
99
+
103
100
// TerraformersMC maven for Mod Menu and EMI.
104
101
maven {
105
102
name = " TerraformersMC"
@@ -128,10 +125,6 @@ subprojects {
128
125
// and so the Kotlin accessor method for it isn't generated for this file.
129
126
" minecraft" (" net.minecraft:minecraft:${rootProject.property(" minecraft-version" )} " )
130
127
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
-
135
128
// Set up the layered mappings with Yarn and my Menu mappings.
136
129
// The average modder would have "mappings"("net.fabricmc:yarn:...") or "mappings"(loom.officialMojangMappings()).
137
130
" mappings" (loom.layered {
@@ -167,50 +160,34 @@ subprojects {
167
160
// Set up "platform" subprojects (non-common subprojects).
168
161
subprojects {
169
162
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" )
174
164
175
165
// Set a different run directory for the server run config,
176
166
// so it won't override client logs/config (or vice versa).
177
167
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" ) {
179
175
runDir = " run/server"
180
176
}
181
177
182
178
// "main" matches the default NeoForge mod's name
183
179
with (mods.maybeCreate(" main" )) {
184
- fun Project.sourceSets () = extensions.getByName<SourceSetContainer >(" sourceSets" )
185
180
sourceSet(sourceSets().getByName(" main" ))
186
181
sourceSet(project(" :common" ).sourceSets().getByName(" main" ))
187
182
}
188
183
}
189
184
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
-
199
185
tasks {
200
186
" 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 })
208
188
}
209
189
210
190
" 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 })
214
191
// The project name will be "fabric" or "neoforge", so this will become the classifier/suffix
215
192
// for the jar. For example: Adorn-3.4.0-fabric.jar
216
193
archiveClassifier.set(project.name)
0 commit comments