Skip to content

Commit f79a05c

Browse files
committed
Update build scripts and configs for multi-platform support and improved automation
- Add and update build.gradle.kts files for common, fabric, and neoforge modules - Integrate Parchment mappings and Kotlin support for both Fabric and NeoForge - Enhance resource processing with dynamic property expansion - Update gradle.properties with new dependency versions and mod metadata - Refactor fabric.mod.json to use property placeholders - Improve GitHub Actions workflow for consistent CI builds - Adjust settings.gradle.kts for unified project configuration - Minor code cleanup in ExampleMod.java
1 parent fc4231f commit f79a05c

File tree

10 files changed

+107
-71
lines changed

10 files changed

+107
-71
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Build
2-
32
on: [push, pull_request]
43

54
jobs:
@@ -11,20 +10,19 @@ jobs:
1110
with:
1211
fetch-depth: 0
1312
fetch-tags: true
14-
1513
- name: Setup JDK 21
1614
uses: actions/setup-java@v4
1715
with:
1816
java-version: '21'
19-
distribution: 'temurin'
20-
21-
- name: Setup Gradle
22-
uses: gradle/actions/setup-gradle@v4
23-
24-
# This is needed to be able to run ./gradlew below
25-
# You can run `git update-index --chmod +x gradlew` then remove this step.
17+
distribution: 'microsoft'
18+
- name: Validate Gradle wrapper
19+
uses: gradle/actions/wrapper-validation@v4
2620
- name: Make Gradle wrapper executable
2721
run: chmod +x ./gradlew
28-
2922
- name: Build with Gradle
30-
run: ./gradlew build
23+
run: ./gradlew build
24+
- name: capture build artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: Artifacts
28+
path: '**/build/libs/'

build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
plugins {
22
kotlin("jvm") version "2.2.0" apply false
33
}
4+
5+
subprojects {
6+
repositories {
7+
maven {
8+
name = "ParchmentMC"
9+
url = uri("https://maven.parchmentmc.org")
10+
}
11+
mavenLocal()
12+
mavenCentral()
13+
google()
14+
}
15+
}

common/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id("java-library")
3+
id("maven-publish")
4+
kotlin("jvm")
5+
}
6+
7+
val modId: String by project
8+
val modVersion: String by project
9+
val minecraftVersion: String by project
10+
11+
base {
12+
archivesName = "$modId-$minecraftVersion-common-$modVersion"
13+
}

fabric/.github/workflows/build.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

fabric/build.gradle.kts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ val minecraftVersion: String by project
88
val loaderVersion: String by project
99
val fabricVersion: String by project
1010
val fabricKotlinVersion: String by project
11-
11+
val parchmentVersion: String by project
12+
val modName: String by project
13+
val modDescription: String by project
14+
val modAuthors: String by project
15+
val modLicense: String by project
1216
val modVersion: String by project
1317
val mavenGroup: String by project
1418
val modId: String by project
1519

1620
base {
17-
archivesName = modId
21+
archivesName = "$modId-$minecraftVersion-fabric-$modVersion"
1822
}
1923

2024
repositories {
@@ -34,17 +38,37 @@ fabricApi {
3438
dependencies {
3539
// To change the versions see the gradle.properties file
3640
minecraft("com.mojang:minecraft:${minecraftVersion}")
37-
mappings(loom.officialMojangMappings())
41+
mappings(loom.layered {
42+
officialMojangMappings()
43+
parchment("org.parchmentmc.data:parchment-${minecraftVersion}:${parchmentVersion}")
44+
})
3845
modImplementation("net.fabricmc:fabric-loader:${loaderVersion}")
3946

4047
// Fabric API. This is technically optional, but you probably want it anyway.
4148
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricVersion}")
4249
modImplementation("net.fabricmc:fabric-language-kotlin:${fabricKotlinVersion}")
50+
51+
implementation(project(":common"))
4352
}
4453

54+
val replacements = mapOf(
55+
"minecraft_version" to minecraftVersion,
56+
"loader_version" to loaderVersion,
57+
"fabric_version" to fabricVersion,
58+
"fabric_kotlin_version" to fabricKotlinVersion,
59+
"parchment_version" to parchmentVersion,
60+
"mod_version" to modVersion,
61+
"group_id" to mavenGroup,
62+
"mod_name" to modName,
63+
"mod_description" to modDescription,
64+
"mod_authors" to modAuthors.replace(", ", "\", \""),
65+
"mod_license" to modLicense,
66+
"mod_id" to modId
67+
)
68+
4569
tasks.named<ProcessResources>("processResources") {
46-
filesMatching("fabric.mod.json") {
47-
expand("version" to modVersion)
70+
filesNotMatching(mutableSetOf("**/*.png")) {
71+
expand(replacements)
4872
}
4973
}
5074

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"schemaVersion": 1,
3-
"id": "examplemod",
4-
"version": "${version}",
5-
"name": "Example Mod",
6-
"description": "This is an example description! Tell everyone what your mod is about!",
3+
"id": "${mod_id}",
4+
"version": "${mod_version}",
5+
"name": "${mod_name}",
6+
"description": "${mod_description}",
77
"authors": [
8-
"Me!"
8+
"${mod_authors}"
99
],
1010
"contact": {
1111
"homepage": "https://fabricmc.net/",
1212
"sources": "https://github.com/FabricMC/fabric-example-mod"
1313
},
14-
"license": "CC0-1.0",
14+
"license": "${mod_license}",
1515
"icon": "assets/examplemod/icon.png",
1616
"environment": "*",
1717
"entrypoints": {

gradle.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33
org.gradle.daemon=true
44
org.gradle.parallel=true
5-
org.gradle.caching=true
6-
org.gradle.configuration-cache=true
75

86
# General Properties
97
minecraftVersion=1.21.6
8+
parchmentVersion=BLEEDING-20250629.110335-3
109
modVersion=1.0.0
1110
mavenGroup=com.example
1211
modId=examplemod
1312
modName=Example Mod
1413
modLicense=All Rights Reserved
14+
# Note: keep authors seperated by ", " and not by "," or anything else
1515
modAuthors=YourNameHere, OtherNameHere
1616
modDescription=Example mod description.\nNewline characters can be used and will be replaced properly.
1717

@@ -24,10 +24,6 @@ fabricKotlinVersion=1.13.4+kotlin.2.2.0
2424
# Fabric Dependencies
2525
fabricVersion=0.128.1+1.21.6
2626

27-
# read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
28-
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
29-
neogradle.subsystems.parchment.minecraftVersion=1.21.5
30-
neogradle.subsystems.parchment.mappingsVersion=2025.06.15
3127
# Environment Properties
3228
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
3329
# The Minecraft version must agree with the Neo version to get a valid artifact
@@ -39,3 +35,4 @@ minecraftVersionRange=[1.21.6]
3935
neoVersion=21.6.20-beta
4036
# The Neo version range can use any version of Neo as bounds
4137
neoVersionRange=[21.6.20-beta,)
38+
kotlinForForgeVersion=5.9.0

neo/build.gradle.kts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,68 @@ plugins {
22
id("java-library")
33
id("maven-publish")
44
id("net.neoforged.gradle.userdev") version "7.0.189"
5+
kotlin("jvm")
56
}
67

78
val mavenGroup: String by project
89
val modId: String by project
910
val minecraftVersion: String by project
1011
val minecraftVersionRange: String by project
12+
val parchmentVersion: String by project
1113
val neoVersion: String by project
1214
val neoVersionRange: String by project
1315
val modName: String by project
1416
val modLicense: String by project
1517
val modVersion: String by project
1618
val modAuthors: String by project
1719
val modDescription: String by project
20+
val kotlinForForgeVersion: String by project
1821

1922
repositories {
23+
maven {
24+
name = "Kotlin for Forge"
25+
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
26+
content { includeGroup("thedarkcolour")}
27+
}
2028
// Add here additional repositories if required by some of the dependencies below.
2129
}
2230

2331
base {
24-
archivesName = modId
32+
archivesName = "$modId-$minecraftVersion-neoforge-$modVersion"
2533
}
2634

2735
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
2836
java {
29-
sourceCompatibility = JavaVersion.VERSION_21
30-
targetCompatibility = JavaVersion.VERSION_21
37+
toolchain {
38+
languageVersion = JavaLanguageVersion.of(21)
39+
}
40+
}
41+
42+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
43+
compilerOptions {
44+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
45+
}
3146
}
3247

48+
3349
//minecraft.accessTransformers.file rootProject.file("src/main/resources/META-INF/accesstransformer.cfg")
3450
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
3551

52+
// minecraftVersion is also a variable name used by the parchment plugin.
53+
val outerMinecraftVersion = minecraftVersion
54+
subsystems {
55+
parchment {
56+
addRepository(false)
57+
parchmentArtifact("org.parchmentmc.data:parchment-${outerMinecraftVersion}:${parchmentVersion}")
58+
}
59+
}
60+
3661
// Default run configurations.
3762
// These can be tweaked, removed, or duplicated as needed.
3863
runs {
3964
// applies to all the run configs below
4065
configureEach {
41-
// Recommended logging data for a userdev environment
66+
// Recommended logging data for an userdev environment
4267
// The markers can be added/remove as needed separated by commas.
4368
// "SCAN": For mods scan.
4469
// "REGISTRIES": For firing of registry events.
@@ -123,8 +148,8 @@ dependencies {
123148
// Example mod dependency using a file as dependency
124149
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
125150

126-
// Example project dependency using a sister or child project:
127-
// implementation project(":myproject")
151+
implementation(project(":common"))
152+
implementation("thedarkcolour:kotlinforforge-neoforge:$kotlinForForgeVersion")
128153

129154
// For more info:
130155
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
@@ -149,9 +174,7 @@ tasks.withType<ProcessResources>().configureEach {
149174
"mod_description" to modDescription,
150175
)
151176
inputs.properties(replaceProperties)
152-
filesMatching("META-INF/neoforge.mods.toml") {
153-
expand(replaceProperties)
154-
}
177+
expand(replaceProperties)
155178
}
156179

157180
// Example configuration to allow publishing using the maven-publish plugin

neo/src/main/java/com/example/examplemod/ExampleMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void onServerStarting(ServerStartingEvent event) {
119119
}
120120

121121
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
122-
@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
122+
@EventBusSubscriber(modid = MODID, value = Dist.CLIENT)
123123
public static class ClientModEvents {
124124
@SubscribeEvent
125125
public static void onClientSetup(FMLClientSetupEvent event) {

settings.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ pluginManagement {
1414
val loomVersion: String by settings
1515
plugins {
1616
id("fabric-loom") version loomVersion apply false
17+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
1718
}
1819
}
1920

20-
plugins {
21-
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
22-
}
21+
2322

2423
val modName: String by settings
2524
rootProject.name = modName

0 commit comments

Comments
 (0)