Skip to content

Commit f0d3bfb

Browse files
committed
🔨 chore: improve build script
1 parent 9e81d23 commit f0d3bfb

5 files changed

Lines changed: 43 additions & 51 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ jobs:
1717
- name: Make Gradle Wrapper executable
1818
run: chmod +x ./gradlew
1919
- name: Build
20-
run: ./gradlew build
21-
- name: Stage JARs for upload
22-
run: |
23-
mkdir -p staging
24-
find versions -path "*/build/libs/*.jar" -exec cp {} staging/ \;
20+
run: ./gradlew buildAndCollect
2521
- name: Upload artifacts
2622
uses: actions/upload-artifact@v4
2723
with:
2824
name: Artifacts
2925
path: |
30-
staging/*.jar
31-
!staging/*-sources.jar
26+
build/libs/*.jar
27+
!build/libs/*-sources.jar

build.gradle.kts

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,21 @@ plugins {
22
id("net.fabricmc.fabric-loom-remap")
33
}
44

5-
val mcMin = property("mod.mc_min") as String
6-
val mcMax = property("mod.mc_max") as String
7-
val mcVersionRange = if (mcMin == mcMax) mcMin else "$mcMin-$mcMax"
8-
val mcDep = if (mcMin == mcMax) mcMin else ">=$mcMin <=$mcMax"
9-
10-
version = "${property("mod.version")}+$mcVersionRange"
11-
base.archivesName = property("mod.name") as String
12-
13-
val requiredJava = when {
14-
sc.current.parsed >= "1.20.6" -> JavaVersion.VERSION_21
15-
sc.current.parsed >= "1.18" -> JavaVersion.VERSION_17
16-
sc.current.parsed >= "1.17" -> JavaVersion.VERSION_16
17-
else -> JavaVersion.VERSION_1_8
18-
}
5+
val mcMin = property("mod.mc_min").toString()
6+
val mcMax = property("mod.mc_max").toString()
7+
val mcDep = if (mcMax.isEmpty()) "~${mcMin}" else ">=${mcMin} <=${mcMax}"
8+
9+
version = "${property("mod.version")}+$mcMin"
10+
base.archivesName = property("mod.name").toString()
11+
12+
val requiredJava = JavaVersion.VERSION_21
1913

2014
repositories {
21-
/**
22-
* Restricts dependency search of the given [groups] to the [maven URL][url],
23-
* improving the setup speed.
24-
*/
2515
fun strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent {
2616
forRepository { maven(url) { name = alias } }
2717
filter { groups.forEach(::includeGroup) }
2818
}
19+
2920
strictMaven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1", "DevAuth", "me.djtheredstoner")
3021
maven("https://maven.isxander.dev/releases") { name = "Xander" }
3122
strictMaven("https://maven.terraformersmc.com/releases", "TerraformersMC", "com.terraformersmc")
@@ -42,16 +33,30 @@ dependencies {
4233
}
4334

4435
loom {
45-
fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json") // Useful for interface injection
36+
fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json")
4637

4738
decompilerOptions.named("vineflower") {
48-
options.put("mark-corresponding-synthetics", "1") // Adds names to lambdas - useful for mixins
39+
options.put("mark-corresponding-synthetics", "1") // adds names to lambdas - useful for mixins
4940
}
5041

51-
runConfigs.all {
52-
ideConfigGenerated(true)
53-
vmArgs("-Dmixin.debug.export=true") // Exports transformed classes for debugging
54-
runDir = "../../run" // Shares the run directory between versions
42+
afterEvaluate {
43+
val mixinJarFile = configurations.runtimeClasspath.get().incoming.artifactView {
44+
componentFilter {
45+
it is ModuleComponentIdentifier && it.group == "net.fabricmc" && it.module == "sponge-mixin"
46+
}
47+
}.files.first()
48+
49+
runConfigs.all {
50+
ideConfigGenerated(true)
51+
52+
vmArg("-XX:+AllowEnhancedClassRedefinition")
53+
vmArg("-javaagent:$mixinJarFile")
54+
property("mixin.debug.export", "true")
55+
56+
runDir = "../../run"
57+
}
58+
59+
runConfigs.remove(runConfigs["server"])
5560
}
5661
}
5762

@@ -63,14 +68,6 @@ java {
6368

6469
tasks {
6570
processResources {
66-
inputs.property("id", project.property("mod.id"))
67-
inputs.property("name", project.property("mod.name"))
68-
inputs.property("version", project.property("mod.version"))
69-
70-
inputs.property("fabric_loader", project.property("deps.fabric_loader"))
71-
inputs.property("minecraft", mcDep)
72-
inputs.property("yacl", project.property("deps.yacl"))
73-
7471
val props = mapOf(
7572
"id" to project.property("mod.id"),
7673
"name" to project.property("mod.name"),
@@ -79,18 +76,16 @@ tasks {
7976
"minecraft" to mcDep,
8077
"yacl" to project.property("deps.yacl")
8178
)
79+
inputs.properties(props)
8280

8381
filesMatching("fabric.mod.json") { expand(props) }
84-
85-
val mixinJava = "JAVA_${requiredJava.majorVersion}"
86-
filesMatching("*.mixins.json") { expand("java" to mixinJava) }
82+
filesMatching("*.mixins.json") { expand("java" to "JAVA_${requiredJava.majorVersion}") }
8783
}
8884

89-
// Builds the version into a shared folder in `build/libs/${mod version}/`
9085
register<Copy>("buildAndCollect") {
9186
group = "build"
9287
from(remapJar.map { it.archiveFile }, remapSourcesJar.map { it.archiveFile })
93-
into(rootProject.layout.buildDirectory.file("libs/${project.property("mod.version")}"))
88+
into(rootProject.layout.buildDirectory.file("libs"))
9489
dependsOn("build")
9590
}
9691
}

src/main/java/dev/cxntered/rankspoof/config/RankPreview.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public int render(GuiGraphics guiGraphics, int x, int y, int width, float v) {
3232
y + 5,
3333
width - 10,
3434
totalHeight - 10,
35-
/*? if <=1.21.5 {*/ /*0, *//*?}*/
35+
/*? if 1.21.4 {*/ /*0, *//*?}*/
3636
null
3737
);
3838

src/main/java/dev/cxntered/rankspoof/mixin/FontMixin.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
@Mixin(Font.class)
1515
public abstract class FontMixin {
1616
@ModifyVariable(
17-
//? if <=1.21.5 {
18-
/*method = "renderText(Lnet/minecraft/util/FormattedCharSequence;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;IIZ)F",
19-
*///?} elif <=1.21.10 {
20-
/*method = "prepareText(Lnet/minecraft/util/FormattedCharSequence;FFIZI)Lnet/minecraft/client/gui/Font$PreparedText;",
21-
*///?} else
17+
//? if >=1.21.11 {
2218
method = "prepareText(Lnet/minecraft/util/FormattedCharSequence;FFIZZI)Lnet/minecraft/client/gui/Font$PreparedText;",
19+
//?} elif >=1.21.6 {
20+
/*method = "prepareText(Lnet/minecraft/util/FormattedCharSequence;FFIZI)Lnet/minecraft/client/gui/Font$PreparedText;",
21+
*///?} else {
22+
/*method = "renderText(Lnet/minecraft/util/FormattedCharSequence;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;IIZ)F",
23+
*///?}
2324
at = @At(value = "HEAD"),
2425
argsOnly = true
2526
)

versions/1.21.11/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
deps.mod_menu=17.0.0-beta.1
22

33
mod.mc_min=1.21.11
4-
mod.mc_max=1.21.11
4+
mod.mc_max=

0 commit comments

Comments
 (0)