Skip to content

Commit a36582e

Browse files
committed
Better build files
1 parent 95b91dd commit a36582e

File tree

10 files changed

+134
-120
lines changed

10 files changed

+134
-120
lines changed

build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ val replacements = file("gradle.properties").inputStream().use { stream ->
77
Properties().apply { load(stream) }
88
}.map { (k, v) -> k.toString() to v.toString() }.toMap()
99

10-
val modId = property("mod_id").toString()
11-
val modVersion = property("mod_version").toString()
12-
val mavenGroup = property("maven_group").toString()
13-
val minecraftVersion = property("minecraft_version").toString()
14-
val yarnMappings = property("yarn_mappings").toString()
10+
val modId: String by project
11+
val modVersion: String by project
12+
val mavenGroup: String by project
13+
val minecraftVersion: String by project
14+
val yarnMappings: String by project
1515

1616
val libs = file("libs")
1717

1818
plugins {
19-
kotlin("jvm") version "1.9.23"
19+
kotlin("jvm") version "1.9.24"
2020
id("org.jetbrains.dokka") version "1.9.20"
2121
id("architectury-plugin") version "3.4-SNAPSHOT"
2222
id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false
@@ -33,7 +33,7 @@ subprojects {
3333

3434
dependencies {
3535
"minecraft"("com.mojang:minecraft:$minecraftVersion")
36-
"mappings"("net.fabricmc:yarn:$yarnMappings:v2")
36+
"mappings"("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2")
3737
}
3838

3939
if (path == ":common") return@subprojects

common/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
val fabricLoaderVersion = property("fabric_loader_version").toString()
2-
val kotlinVersion = property("kotlin_version").toString()
3-
val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString()
1+
val modId: String by project
2+
val fabricLoaderVersion: String by project
3+
val kotlinVersion: String by project
4+
val kotlinxCoroutinesVersion: String by project
45

56
architectury { common("fabric", "forge", "neoforge") }
67

78
loom {
89
silentMojangMappingsLicense()
9-
accessWidenerPath = File("src/main/resources/lambda.accesswidener")
10+
accessWidenerPath = File("src/main/resources/$modId.accesswidener")
1011
}
1112

1213
repositories {

fabric/build.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
val fabricLoaderVersion = property("fabric_loader_version").toString()
2-
val fabricApiVersion = property("fabric_api_version").toString()
3-
val kotlinFabricVersion = property("kotlin_fabric_version").toString()
1+
val minecraftVersion: String by project
2+
val fabricLoaderVersion: String by project
3+
val fabricApiVersion: String by project
4+
val kotlinFabricVersion: String by project
45

56
base.archivesName = "${base.archivesName.get()}-fabric"
67

@@ -56,7 +57,7 @@ dependencies {
5657
includeLib("dev.babbaj:nether-pathfinder:1.5")
5758

5859
// Add mods to the mod jar
59-
includeMod("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
60+
includeMod("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion+$minecraftVersion")
6061
includeMod("net.fabricmc:fabric-language-kotlin:$kotlinFabricVersion")
6162
includeMod("baritone-api:baritone-unoptimized-fabric:1.10.2")
6263

@@ -69,6 +70,9 @@ dependencies {
6970
}
7071

7172
tasks {
73+
// Access wideners are the successor of the mixins accessor
74+
// that were used in the past to access private fields and methods.
75+
// They allow you to make field, method, and class access public.
7276
remapJar {
7377
injectAccessWidener = true
7478
}

fabric/src/main/resources/fabric.mod.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"schemaVersion": 1,
3-
"id": "${mod_id}",
4-
"version": "${mod_version}",
3+
"id": "${modId}",
4+
"version": "${modVersion}",
55
"name": "Lambda",
6-
"description": "${mod_description}",
6+
"description": "${modDescription}",
77
"authors": [
88
"Constructor"
99
],
@@ -29,7 +29,7 @@
2929
"fabricloader": ">=0.15.1",
3030
"fabric-api": ">=0.91.3+1.20.4",
3131
"minecraft": "1.20.4",
32-
"fabric-language-kotlin": ">=${kotlin_fabric_version}",
32+
"fabric-language-kotlin": ">=${kotlinFabricVersion}",
3333
"java": ">=17"
3434
}
3535
}

forge/build.gradle.kts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
val forgeVersion = property("forge_version").toString()
2-
val mixinExtrasVersion = property("mixinextras_version").toString()
3-
val kotlinForgeVersion = property("kotlin_forge_version").toString()
1+
val minecraftVersion: String by project
2+
val forgeVersion: String by project
3+
val mixinExtrasVersion: String by project
4+
val kotlinForgeVersion: String by project
45

5-
base.archivesName.set("${base.archivesName.get()}-forge")
6+
base.archivesName = "${base.archivesName.get()}-forge"
67

78
architectury {
89
platformSetupLoomIde()
@@ -13,14 +14,26 @@ loom {
1314
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
1415

1516
forge {
17+
// This is required to convert the access wideners to the forge
18+
// format, access transformers.
1619
convertAccessWideners = true
17-
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
20+
21+
// Add the mod's mixins to the list of mixins to be applied.
22+
// In the extraordinary case that you need to add mixins for
23+
// different mod loaders, you can add them using the
24+
// `extraAccessWideners` property.
25+
// And then add them to the `mixinConfig` function.
1826
mixinConfig("lambda.mixins.common.json")
1927
}
2028
}
2129

2230
repositories {
23-
maven("https://cursemaven.com")
31+
// You can add more repositories here if you plan
32+
// on using environment-specific dependencies.
33+
// If you simply want to add a global repository,
34+
// you can add it to the `settings.gradle.kts` file
35+
// in the base of the project and gradle will do the
36+
// rest for you.
2437
maven("https://thedarkcolour.github.io/KotlinForForge/")
2538
}
2639

@@ -58,7 +71,7 @@ fun DependencyHandlerScope.setupConfigurations() {
5871

5972
dependencies {
6073
// Forge API
61-
forge("net.minecraftforge:forge:$forgeVersion")
74+
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
6275

6376
// Add dependencies on the required Kotlin modules.
6477
includeLib("org.reflections:reflections:0.10.2")
@@ -84,10 +97,6 @@ dependencies {
8497
}
8598

8699
tasks {
87-
remapJar {
88-
injectAccessWidener = true
89-
}
90-
91100
sourceSets.forEach {
92101
val dir = layout.buildDirectory.dir("sourcesSets/${it.name}")
93102
it.output.setResourcesDir(dir)
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
modLoader = "kotlinforforge"
2-
loaderVersion = "[4.10,)"
2+
loaderVersion = "[$kotlinForgeVersion,)"
33
license = "GNU General Public License v3.0"
44
issueTrackerURL = "https://github.com/lambda-client/lambda/issues"
55

66
[[mods]]
7-
modId = "lambda"
8-
version = "${mod_version}"
7+
modId = "${modId}"
8+
version = "${modVersion}"
99
displayName = "Lambda"
10-
authors = "${authors}"
11-
description = "${mod_description}"
10+
authors = "${modAuthors}"
11+
description = "${modDescription}"
1212
logoFile = "assets/lambda/lambda.png"
1313
displayTest = "IGNORE_ALL_VERSION"
1414

15-
[[dependencies.lambda]]
15+
[[dependencies.${modId}]]
1616
modId = "forge"
1717
mandatory = true
18-
versionRange = "[49,)"
18+
versionRange = "[${forgeVersion},)"
1919
ordering = "NONE"
2020
side = "CLIENT"
2121

22-
[[dependencies.lambda]]
22+
[[dependencies.${modId}]]
2323
modId = "minecraft"
2424
mandatory = true
25-
versionRange = "[1.20.4,)"
25+
versionRange = "[${minecraftVersion},)"
2626
ordering = "NONE"
2727
side = "CLIENT"
2828

29-
[[dependencies.lambda]]
29+
[[dependencies.${modId}]]
3030
modId = "kotlinforforge"
3131
mandatory = true
32-
versionRange = "[4.10,)"
32+
versionRange = "[${kotlinForgeVersion},)"
3333
ordering = "NONE"
3434
side = "CLIENT"

gradle.properties

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Lambda https://github.com/lambda-client/lambda
2-
mod_id=lambda
3-
mod_version=1.0.0
4-
mod_description=Minecraft utility mod coded in Kotlin
5-
maven_group=com.lambda
6-
authors=Constructor
2+
modId=lambda
3+
modVersion=1.0.0
4+
modDescription=Minecraft utility mod coded in Kotlin
5+
mavenGroup=com.lambda
6+
modAuthors=Constructor, Blade, Edouard127
77

88
# General
9-
minecraft_version=1.20.4
10-
mixinextras_version=0.3.5
11-
kotlin_version=1.9.23
12-
kotlinx_coroutines_version=1.8.0
9+
minecraftVersion=1.20.4
10+
mixinExtrasVersion=0.3.5
11+
kotlinVersion=1.9.24
12+
kotlinxCoroutinesVersion=1.8.0
1313

1414
# Fabric https://fabricmc.net/develop/
15-
fabric_loader_version=0.15.7
16-
yarn_mappings=1.20.4+build.3
17-
fabric_api_version=0.96.4+1.20.4
18-
kotlin_fabric_version=1.10.19+kotlin.1.9.23
15+
fabricLoaderVersion=0.15.7
16+
yarnMappings=build.3
17+
fabricApiVersion=0.96.4
18+
kotlinFabricVersion=1.10.19+kotlin.1.9.23
1919

2020
# Forge https://files.minecraftforge.net/
21-
forge_version=1.20.4-49.0.31
22-
kotlin_forge_version=4.10.0
21+
forgeVersion=49.0.31
22+
kotlinForgeVersion=4.10.0
2323

2424
# NeoForge https://neoforged.net
25-
neo_version=20.4.234
25+
neoVersion=20.4.234
2626

2727
# Kotlin https://kotlinlang.org/
2828
kotlin.code.style=official

neoforge/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
val neoVersion = property("neo_version").toString()
2-
val kotlinForgeVersion = property("kotlin_forge_version").toString()
1+
val neoVersion: String by project
2+
val kotlinForgeVersion: String by project
33

4-
base.archivesName.set("${base.archivesName.get()}-neoforge")
4+
base.archivesName = "${base.archivesName.get()}-neoforge"
55

66
architectury {
77
platformSetupLoomIde()
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
modLoader = "kotlinforforge"
2-
loaderVersion = "[4.10,)"
2+
loaderVersion = "[${kotlinForgeVersion},)"
33
license = "GNU General Public License v3.0"
44
issueTrackerURL = "https://github.com/lambda-client/lambda/issues"
55
#updateJSONURL = "https://raw.githubusercontent.com/lambda-client/lambda/main/update.json"
66

77
[[mods]]
8-
modId = "lambda"
9-
version = "${mod_version}"
10-
displayName = "Lambda"
11-
authors = "${authors}"
12-
description = "${mod_description}"
13-
logoFile = "assets/lambda/lambda.png"
14-
displayTest = "IGNORE_ALL_VERSION"
8+
modId = "${modId}"
9+
version = "${modVersion}"
10+
displayName = "Lambda"
11+
authors = "${modAuthors}"
12+
description = "${modDescription}"
13+
logoFile = "assets/lambda/lambda.png"
14+
displayTest = "IGNORE_ALL_VERSION"
1515

1616
[[mixins]]
17-
config = "lambda.mixins.common.json"
17+
config = "lambda.mixins.common.json"
1818

19-
[[dependencies.lambda]]
20-
modId = "neoforge"
21-
mandatory = true
22-
type = "required"
23-
versionRange = "[20.4.0,)"
24-
ordering = "NONE"
25-
side = "CLIENT"
19+
[[dependencies.${modId}]]
20+
modId = "neoforge"
21+
mandatory = true
22+
type = "required"
23+
versionRange = "[${neoVersion},)"
24+
ordering = "NONE"
25+
side = "CLIENT"
2626

27-
[[dependencies.lambda]]
28-
modId = "minecraft"
29-
mandatory = true
30-
type = "required"
31-
versionRange = "[1.20.4,)"
32-
ordering = "NONE"
33-
side = "CLIENT"
27+
[[dependencies.${modId}]]
28+
modId = "minecraft"
29+
mandatory = true
30+
type = "required"
31+
versionRange = "[${minecraftVersion},)"
32+
ordering = "NONE"
33+
side = "CLIENT"
3434

35-
[[dependencies.lambda]]
36-
modId = "kotlinforforge"
37-
mandatory = true
38-
type = "required"
39-
versionRange = "[4.10,)"
40-
ordering = "NONE"
41-
side = "CLIENT"
35+
[[dependencies.${modId}]]
36+
modId = "kotlinforforge"
37+
mandatory = true
38+
type = "required"
39+
versionRange = "[${kotlinForgeVersion},)"
40+
ordering = "NONE"
41+
side = "CLIENT"

0 commit comments

Comments
 (0)