Skip to content

Commit 7a152e1

Browse files
committed
Refactor: Buildscripts
1 parent 36d975f commit 7a152e1

File tree

5 files changed

+97
-46
lines changed

5 files changed

+97
-46
lines changed

build.gradle.kts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22
import net.fabricmc.loom.task.RemapJarTask
33

4-
val modId = project.properties["mod_id"].toString()
5-
val modVersion = project.properties["mod_version"].toString()
6-
val mavenGroup = project.properties["maven_group"].toString()
7-
val minecraftVersion = project.properties["minecraft_version"].toString()
8-
val yarnMappings = project.properties["yarn_mappings"].toString()
4+
val modId = property("mod_id").toString()
5+
val modVersion = property("mod_version").toString()
6+
val mavenGroup = property("maven_group").toString()
7+
val minecraftVersion = property("minecraft_version").toString()
8+
val yarnMappings = property("yarn_mappings").toString()
99

1010
plugins {
1111
kotlin("jvm") version ("1.9.22")
@@ -22,6 +22,7 @@ architectury {
2222
subprojects {
2323
apply(plugin = "dev.architectury.loom")
2424
apply(plugin = "org.jetbrains.dokka")
25+
2526
dependencies {
2627
"minecraft"("com.mojang:minecraft:$minecraftVersion")
2728
"mappings"("net.fabricmc:yarn:$yarnMappings:v2")
@@ -64,21 +65,21 @@ allprojects {
6465
version = modVersion
6566

6667
repositories {
68+
maven("https://impactdevelopment.github.io/maven/") { name = "ImpactDev" }
6769
maven("https://api.modrinth.com/maven")
6870
maven("https://jitpack.io")
69-
maven("https://maven.shedaniel.me/") {
70-
name = "Architectury"
71-
}
71+
maven("https://maven.shedaniel.me/") { name = "Architectury" }
7272
maven("https://maven.terraformersmc.com/releases/")
73-
}
7473

75-
tasks {
76-
withType<JavaCompile> {
77-
options.encoding = "UTF-8"
78-
options.release = 17
79-
}
80-
compileKotlin {
81-
kotlinOptions.jvmTarget = "17"
74+
flatDir {
75+
dirs("libs") // TODO: Absolute path
8276
}
8377
}
78+
79+
java {
80+
// withSourcesJar() // Uncomment this line when the plugin system is ready
81+
82+
sourceCompatibility = JavaVersion.VERSION_17
83+
targetCompatibility = JavaVersion.VERSION_17
84+
}
8485
}

common/build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
val fabricLoaderVersion = project.properties["fabric_loader_version"].toString()
2-
val fabricKotlinVersion = project.properties["fabric_kotlin_version"].toString()
3-
val mixinExtrasVersion = project.properties["mixinextras_version"].toString()
1+
val fabricLoaderVersion = property("fabric_loader_version").toString()
2+
val fabricKotlinVersion = property("fabric_kotlin_version").toString()
3+
val mixinExtrasVersion = property("mixinextras_version").toString()
4+
val kotlinXCoroutineVersion = property("kotlinx_coroutines_version").toString()
45

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

@@ -9,10 +10,9 @@ loom {
910
}
1011

1112
repositories {
12-
maven("https://maven.fabricmc.net/") {
13-
name = "Fabric"
14-
}
13+
maven("https://maven.fabricmc.net/") { name = "Fabric" }
1514
maven("https://jitpack.io")
15+
1616
mavenCentral()
1717
mavenLocal()
1818
}
@@ -21,11 +21,15 @@ dependencies {
2121
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
2222
// Do NOT use other classes from fabric loader
2323
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
24+
2425
// Add dependencies on the required Kotlin modules.
2526
modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
2627
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!)
28+
29+
// Baritone
2730
}
2831

32+
// Avoid nested jars
2933
tasks.named("remapJar") {
3034
enabled = false
3135
}

fabric/build.gradle.kts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
val fabricLoaderVersion = project.properties["fabric_loader_version"].toString()
2-
val fabricApiVersion = project.properties["fabric_api_version"].toString()
3-
val fabricKotlinVersion = project.properties["fabric_kotlin_version"].toString()
1+
val fabricLoaderVersion = property("fabric_loader_version").toString()
2+
val fabricApiVersion = property("fabric_api_version").toString()
3+
val fabricKotlinVersion = property("fabric_kotlin_version").toString()
44

55
architectury {
66
platformSetupLoomIde()
@@ -20,16 +20,39 @@ val common: Configuration by configurations.creating {
2020
configurations["developmentFabric"].extendsFrom(this)
2121
}
2222

23-
dependencies {
24-
common(project(":common", configuration = "namedElements")) {
25-
isTransitive = false
23+
val includeLib: Configuration by configurations.creating
24+
val includeMod: Configuration by configurations.creating
25+
26+
fun DependencyHandlerScope.setupConfigurations() {
27+
includeLib.dependencies.forEach {
28+
implementation(it)
29+
include(it)
2630
}
27-
shadowCommon(project(path = ":common", configuration = "transformProductionFabric")) {
28-
isTransitive = false
31+
32+
includeMod.dependencies.forEach {
33+
modImplementation(it)
34+
include(it)
2935
}
30-
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
31-
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
32-
modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
36+
}
37+
38+
dependencies {
39+
// Fabric API
40+
includeMod("net.fabricmc:fabric-loader:$fabricLoaderVersion")
41+
includeMod("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
42+
includeMod("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
43+
44+
// Add dependencies on the required Kotlin modules.
45+
// includeLib(...)
46+
47+
// Add mods to the mod jar
48+
// includeMod(...)
49+
50+
// Common (Do not touch)
51+
common(project(":common", configuration = "namedElements")) { isTransitive = false }
52+
shadowCommon(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false }
53+
54+
// Finish the configuration
55+
setupConfigurations()
3356
}
3457

3558
tasks {

forge/build.gradle.kts

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
val forgeVersion = project.properties["forge_version"].toString()
2-
val kotlinForgeVersion = project.properties["kotlin_forge_version"].toString()
3-
val mixinExtrasVersion = project.properties["mixinextras_version"].toString()
1+
val forgeVersion = property("forge_version").toString()
2+
val kotlinForgeVersion = property("kotlin_forge_version").toString()
3+
val mixinExtrasVersion = property("mixinextras_version").toString()
44

55
architectury {
66
platformSetupLoomIde()
@@ -33,17 +33,39 @@ val common: Configuration by configurations.creating {
3333
configurations["developmentForge"].extendsFrom(this)
3434
}
3535

36-
dependencies {
37-
forge("net.minecraftforge:forge:$forgeVersion")
38-
implementation("thedarkcolour:kotlinforforge:$kotlinForgeVersion")
39-
common(project(":common", configuration = "namedElements")) {
40-
isTransitive = false
36+
val includeLib: Configuration by configurations.creating
37+
val includeMod: Configuration by configurations.creating
38+
39+
fun DependencyHandlerScope.setupConfigurations() {
40+
includeLib.dependencies.forEach {
41+
implementation(it)
42+
include(it)
4143
}
42-
shadowCommon(project(path = ":common", configuration = "transformProductionForge")) {
43-
isTransitive = false
44+
45+
includeMod.dependencies.forEach {
46+
modImplementation(it)
47+
include(it)
4448
}
45-
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!)
46-
implementation(include("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion")!!)
49+
}
50+
51+
dependencies {
52+
// Forge API
53+
forge("net.minecraftforge:forge:$forgeVersion")
54+
55+
// Add dependencies on the required Kotlin modules.
56+
includeLib("thedarkcolour:kotlinforforge:$kotlinForgeVersion")
57+
includeLib(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!)
58+
includeLib("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion")
59+
60+
// Add mods to the mod jar
61+
// includeMod(...)
62+
63+
// Common (Do not touch)
64+
common(project(":common", configuration = "namedElements")) { isTransitive = false }
65+
shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
66+
67+
// Finish the configuration
68+
setupConfigurations()
4769
}
4870

4971
tasks {

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ maven_group=com.lambda
66
# General
77
minecraft_version=1.20.4
88
mixinextras_version=0.3.5
9+
kotlinx_coroutines_version=1.8.0
910

1011
# Architectury https://docs.architectury.dev/start
1112
enabled_platforms=fabric,forge
@@ -26,4 +27,4 @@ kotlin.code.style=official
2627

2728
# Gradle https://gradle.org/
2829
org.gradle.jvmargs=-Xmx2048M
29-
org.gradle.parallel=true4
30+
org.gradle.parallel=true4

0 commit comments

Comments
 (0)