Skip to content

Commit 6e9bc06

Browse files
committed
Refactor: Build scripts
1 parent dc57931 commit 6e9bc06

File tree

9 files changed

+81
-90
lines changed

9 files changed

+81
-90
lines changed

common/build.gradle.kts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import java.util.Properties
2+
13
val fabricLoaderVersion = property("fabric_loader_version").toString()
24
val mixinExtrasVersion = property("mixinextras_version").toString()
35
val kotlinVersion = property("kotlin_version").toString()
46
val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString()
5-
val architecturyVersion = property("architectury_version").toString()
67

7-
architectury { common("fabric", "forge", "neoforge") }
8+
architectury { common("fabric", "forge", "neoforge", "quilt") }
89

910
loom {
1011
silentMojangMappingsLicense()
@@ -31,8 +32,17 @@ dependencies {
3132
modImplementation("baritone-api:baritone-unoptimized-fabric:1.10.2")
3233
}
3334

34-
// Avoid nested jars
35-
tasks.named("remapJar") {
36-
enabled = false
35+
tasks {
36+
remapJar {
37+
enabled = false
38+
}
39+
40+
processResources {
41+
Properties().apply {
42+
load(project.rootProject.file("gradle.properties").inputStream())
43+
}.forEach { key, value ->
44+
inputs.property(key.toString(), value)
45+
}
46+
}
3747
}
3848

common/src/main/java/com/lambda/mixin/render/LightmapTextureManagerMixin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.injection.At;
99
import org.spongepowered.asm.mixin.injection.Inject;
10-
import org.spongepowered.asm.mixin.injection.ModifyArgs;
10+
import org.spongepowered.asm.mixin.injection.ModifyArg;
1111
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12-
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
1312

1413
@Mixin(LightmapTextureManager.class)
1514
public class LightmapTextureManagerMixin {
16-
@ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"))
17-
private void updateModify(Args args) {
15+
@ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"), index = 2)
16+
private int updateModify(int x) {
1817
if (Fullbright.INSTANCE.isEnabled() || XRay.INSTANCE.isEnabled()) {
19-
args.set(2, 0xFFFFFFFF);
18+
return 0xFFFFFFFF;
2019
}
20+
return x;
2121
}
2222

2323
@Inject(method = "getDarknessFactor(F)F", at = @At("HEAD"), cancellable = true)

common/src/main/kotlin/com/lambda/command/CommandManager.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ object CommandManager : Configurable(LambdaConfig), Loadable {
117117
override fun load(): String {
118118
Reflections(
119119
ConfigurationBuilder()
120-
// Let's hope the maintainer of the library releases a new version soon
121-
// because this is horrible, it takes multiple SECONDS to scan the classpath,
122-
// and it's not even that big
123-
//
124-
// The culprit may be due to [ClasspathHelper.forClassLoader()] loading
125-
// the classes from the main thread while we are in a different thread.
126-
// If this is the case I wish the maintainer a very bad day.
127-
.addUrls(ClasspathHelper.forJavaClassPath())
128-
.addUrls(ClasspathHelper.forClassLoader())
129-
.filterInputsBy { it.contains("lambda") }
130120
.forPackage("com.lambda.command.commands")
131121
.setScanners(Scanners.SubTypes)
132122
).getSubTypesOf(LambdaCommand::class.java).forEach { commandClass ->

common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ object ModuleRegistry : Loadable {
2222
override fun load(): String {
2323
Reflections(
2424
ConfigurationBuilder()
25-
// Let's hope the maintainer of the library releases a new version soon
26-
// because this is horrible, it takes multiple SECONDS to scan the classpath,
27-
// and it's not even that big
28-
//
29-
// The culprit may be due to [ClasspathHelper.forClassLoader()] loading
30-
// the classes from the main thread while we are in a different thread.
31-
// If this is the case I wish the maintainer a very bad day.
32-
.addUrls(ClasspathHelper.forJavaClassPath())
33-
.addUrls(ClasspathHelper.forClassLoader())
34-
.filterInputsBy { it.contains("lambda") }
3525
.forPackage("com.lambda.module.modules")
3626
.addScanners(Scanners.SubTypes)
3727
).getSubTypesOf(Module::class.java).forEach { moduleClass ->

fabric/build.gradle.kts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
val fabricLoaderVersion = property("fabric_loader_version").toString()
22
val fabricApiVersion = property("fabric_api_version").toString()
3-
val architecturyVersion = property("architectury_version").toString()
43
val kotlinFabricVersion = property("kotlin_fabric_version").toString()
54

5+
base.archivesName.set("${base.archivesName.get()}-fabric")
6+
67
architectury {
78
platformSetupLoomIde()
89
fabric()
910
}
1011

11-
base.archivesName.set("${base.archivesName.get()}-fabric")
12-
1312
loom {
1413
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
1514
enableTransitiveAccessWideners.set(true)
@@ -19,10 +18,16 @@ val common: Configuration by configurations.creating {
1918
configurations.compileClasspath.get().extendsFrom(this)
2019
configurations.runtimeClasspath.get().extendsFrom(this)
2120
configurations["developmentFabric"].extendsFrom(this)
21+
isCanBeResolved = true
22+
isCanBeConsumed = false
2223
}
2324

2425
val includeLib: Configuration by configurations.creating
2526
val includeMod: Configuration by configurations.creating
27+
val shadowBundle: Configuration by configurations.creating {
28+
isCanBeResolved = true
29+
isCanBeConsumed = false
30+
}
2631

2732
fun DependencyHandlerScope.setupConfigurations() {
2833
includeLib.dependencies.forEach {
@@ -34,6 +39,11 @@ fun DependencyHandlerScope.setupConfigurations() {
3439
modImplementation(it)
3540
include(it)
3641
}
42+
43+
shadowBundle.dependencies.forEach {
44+
shadowCommon(it)
45+
shadow(it)
46+
}
3747
}
3848

3949
dependencies {
@@ -52,27 +62,20 @@ dependencies {
5262

5363
// Common (Do not touch)
5464
common(project(":common", configuration = "namedElements")) { isTransitive = false }
55-
shadowCommon(project(":common", configuration = "transformProductionFabric")) { isTransitive = false }
65+
shadowBundle(project(":common", configuration = "transformProductionFabric"))
5666

5767
// Finish the configuration
5868
setupConfigurations()
5969
}
6070

6171
tasks {
62-
processResources {
63-
inputs.property("group", project.group)
64-
inputs.property("version", project.version)
72+
remapJar {
73+
injectAccessWidener = true
74+
}
6575

76+
processResources {
6677
filesMatching("fabric.mod.json") {
67-
expand(getProperties())
68-
expand(mutableMapOf(
69-
"group" to project.group,
70-
"version" to project.version,
71-
))
78+
expand(project(":common").properties)
7279
}
7380
}
74-
75-
remapJar {
76-
injectAccessWidener.set(true)
77-
}
7881
}

forge/build.gradle.kts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
val forgeVersion = property("forge_version").toString()
2-
val architecturyVersion = property("architectury_version").toString()
32
val mixinExtrasVersion = property("mixinextras_version").toString()
43
val kotlinForgeVersion = property("kotlin_forge_version").toString()
54

5+
base.archivesName.set("${base.archivesName.get()}-forge")
6+
67
architectury {
78
platformSetupLoomIde()
89
forge()
910
}
1011

11-
base.archivesName.set("${base.archivesName.get()}-forge")
12-
1312
loom {
1413
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
1514

@@ -29,11 +28,16 @@ val common: Configuration by configurations.creating {
2928
configurations.compileClasspath.get().extendsFrom(this)
3029
configurations.runtimeClasspath.get().extendsFrom(this)
3130
configurations["developmentForge"].extendsFrom(this)
31+
isCanBeResolved = true
32+
isCanBeConsumed = false
3233
}
3334

3435
val includeLib: Configuration by configurations.creating
3536
val includeMod: Configuration by configurations.creating
36-
val shadowInclude: Configuration by configurations.creating
37+
val shadowBundle: Configuration by configurations.creating {
38+
isCanBeResolved = true
39+
isCanBeConsumed = false
40+
}
3741

3842
fun DependencyHandlerScope.setupConfigurations() {
3943
includeLib.dependencies.forEach {
@@ -45,6 +49,11 @@ fun DependencyHandlerScope.setupConfigurations() {
4549
forgeRuntimeLibrary(it)
4650
include(it)
4751
}
52+
53+
shadowBundle.dependencies.forEach {
54+
shadowCommon(it)
55+
shadow(it)
56+
}
4857
}
4958

5059
dependencies {
@@ -67,23 +76,20 @@ dependencies {
6776

6877
// Common (Do not touch)
6978
common(project(":common", configuration = "namedElements")) { isTransitive = false }
70-
shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
79+
shadowBundle(project(path = ":common", configuration = "transformProductionForge"))
7180

7281
// Finish the configuration
7382
setupConfigurations()
7483
}
7584

7685
tasks {
77-
processResources {
78-
inputs.property("group", project.group)
79-
inputs.property("version", project.version)
86+
remapJar {
87+
injectAccessWidener = true
88+
}
8089

90+
processResources {
8191
filesMatching("META-INF/mods.toml") {
82-
expand(getProperties())
83-
expand(mutableMapOf(
84-
"group" to project.group,
85-
"version" to project.version,
86-
))
92+
expand(project(":common").properties)
8793
}
8894
}
8995

gradle.properties

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ mixinextras_version=0.3.5
1111
kotlin_version=1.9.23
1212
kotlinx_coroutines_version=1.8.0
1313

14-
# Architectury https://docs.architectury.dev/start
15-
enabled_platforms=fabric,forge
16-
architectury_version=11.1.13
17-
1814
# Fabric https://fabricmc.net/develop/
1915
fabric_loader_version=0.15.7
2016
yarn_mappings=1.20.4+build.3
@@ -30,7 +26,8 @@ neo_version=20.4.196
3026

3127
# Quilt https://quiltmc.org/
3228
quilt_version=0.24.0
33-
quilted_fabric_version=8.0.0-alpha.4+0.91.6-1.20.2
29+
quilted_fabric_version=9.0.0-alpha.5+0.96.11-1.20.4
30+
kotlin_quilt_version=4.0.0+kt.1.9.23+flk.1.10.19
3431

3532
# Kotlin https://kotlinlang.org/
3633
kotlin.code.style=official

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-4-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

neoforge/build.gradle.kts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
val neoVersion = property("neo_version").toString()
2-
val architecturyVersion = property("architectury_version").toString()
32
val kotlinForgeVersion = property("kotlin_forge_version").toString()
43

4+
base.archivesName.set("${base.archivesName.get()}-neoforge")
5+
56
architectury {
67
platformSetupLoomIde()
78
neoForge()
89
}
910

10-
base.archivesName.set("${base.archivesName.get()}-neoforge")
11-
1211
loom {
1312
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
13+
1414
neoForge {
1515
enableTransitiveAccessWideners = true
1616
}
@@ -25,23 +25,32 @@ val common: Configuration by configurations.creating {
2525
configurations.compileClasspath.get().extendsFrom(this)
2626
configurations.runtimeClasspath.get().extendsFrom(this)
2727
configurations["developmentNeoForge"].extendsFrom(this)
28+
isCanBeResolved = true
29+
isCanBeConsumed = false
2830
}
2931

3032
val includeLib: Configuration by configurations.creating
3133
val includeMod: Configuration by configurations.creating
34+
val shadowBundle: Configuration by configurations.creating {
35+
isCanBeResolved = true
36+
isCanBeConsumed = false
37+
}
3238

3339
fun DependencyHandlerScope.setupConfigurations() {
3440
includeLib.dependencies.forEach {
3541
implementation(it)
36-
forgeRuntimeLibrary(it)
3742
include(it)
3843
}
3944

4045
includeMod.dependencies.forEach {
4146
implementation(it)
42-
forgeRuntimeLibrary(it)
4347
include(it)
4448
}
49+
50+
shadowBundle.dependencies.forEach {
51+
shadowCommon(it)
52+
shadow(it)
53+
}
4554
}
4655

4756
dependencies {
@@ -57,34 +66,20 @@ dependencies {
5766

5867
// Common (Do not touch)
5968
common(project(":common", configuration = "namedElements")) { isTransitive = false }
60-
shadowCommon(project(path = ":common", configuration = "transformProductionNeoForge")) { isTransitive = false }
69+
shadowBundle(project(path = ":common", configuration = "transformProductionNeoForge"))
6170

6271
// Finish the configuration
6372
setupConfigurations()
6473
}
6574

6675
tasks {
67-
processResources {
68-
inputs.property("group", project.group)
69-
inputs.property("version", project.version)
70-
71-
filesMatching("META-INF/mods.toml") {
72-
expand(getProperties())
73-
expand(mutableMapOf(
74-
"group" to project.group,
75-
"version" to project.version,
76-
))
77-
}
78-
}
79-
8076
remapJar {
81-
atAccessWideners.add("lambda.accesswidener")
82-
injectAccessWidener.set(true)
77+
injectAccessWidener = true
8378
}
8479

85-
sourceSets.forEach {
86-
val dir = layout.buildDirectory.dir("sourcesSets/${it.name}")
87-
it.output.setResourcesDir(dir)
88-
it.java.destinationDirectory.set(dir)
80+
processResources {
81+
filesMatching("META-INF/mods.toml") {
82+
expand(project(":common").properties)
83+
}
8984
}
9085
}

0 commit comments

Comments
 (0)