almostunified/Forge/build.gradle.kts

93 lines
3.4 KiB
Text
Raw Normal View History

2022-05-31 10:50:46 -04:00
val minecraftVersion: String by project
2023-02-01 14:43:30 -05:00
val modId: String by project
2023-07-28 18:59:02 -04:00
val junitVersion: String by project
val forgeVersion: String by project
2023-02-01 14:43:30 -05:00
val forgeRecipeViewer: String by project
val jeiVersion: String by project
2023-07-28 18:59:02 -04:00
val reiVersion: String by project
2024-02-21 11:24:51 -05:00
val emiVersion: String by project
2022-05-31 10:50:46 -04:00
2023-07-28 18:59:02 -04:00
val extraModsPrefix = "extra-mods"
plugins {
2023-08-05 18:36:18 -04:00
id("com.github.johnrengelman.shadow") version "8.1.1"
}
2022-05-31 10:50:46 -04:00
2023-02-01 14:43:30 -05:00
architectury {
platformSetupLoomIde()
forge()
2022-05-31 10:50:46 -04:00
}
loom {
2023-07-28 18:59:02 -04:00
if (project.findProperty("enableAccessWidener") == "true") { // optional property for `gradle.properties`
2023-02-01 14:43:30 -05:00
accessWidenerPath.set(project(":Common").loom.accessWidenerPath)
forge {
convertAccessWideners.set(true)
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
2022-05-31 10:50:46 -04:00
}
2023-02-01 14:43:30 -05:00
println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}")
2022-05-31 10:50:46 -04:00
}
forge {
2023-02-01 14:43:30 -05:00
mixinConfigs("$modId-common.mixins.json" /*, "$modId-forge.mixins.json"*/)
}
}
2022-06-23 12:47:03 -04:00
2023-07-28 18:59:02 -04:00
repositories {
flatDir {
name = extraModsPrefix
dir(file("$extraModsPrefix-$minecraftVersion"))
}
}
2023-02-01 14:43:30 -05:00
val common by configurations
val shadowCommon by configurations
val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output
2023-07-28 18:59:02 -04:00
2022-05-31 10:50:46 -04:00
dependencies {
2023-06-14 05:48:49 -04:00
// loader
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
2023-06-14 05:48:49 -04:00
// common module
2023-02-01 14:43:30 -05:00
common(project(":Common", "namedElements")) { isTransitive = false }
shadowCommon(project(":Common", "transformProductionForge")) { isTransitive = false }
2022-10-17 14:57:09 -04:00
2023-06-14 05:48:49 -04:00
// compile time mods
2023-07-28 19:43:23 -04:00
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion") { // required for common jei plugin
2023-06-14 05:48:49 -04:00
isTransitive = false // prevents breaking the forge runtime
}
2023-07-28 19:43:23 -04:00
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for common rei plugin
2024-02-21 11:24:51 -05:00
modCompileOnly("dev.emi:emi-forge:$emiVersion+$minecraftVersion:api") // required for common emi plugin
2023-06-14 05:48:49 -04:00
// runtime mods
when (forgeRecipeViewer) {
2022-10-17 14:57:09 -04:00
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
2023-07-28 18:59:02 -04:00
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
2024-02-21 11:24:51 -05:00
"emi" -> modLocalRuntime("dev.emi:emi-forge:$emiVersion+$minecraftVersion")
else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer")
}
2022-05-31 10:50:46 -04:00
2023-07-28 18:59:02 -04:00
/**
* helps to load mods in development through an extra directory
* sadly, this does not support transitive dependencies
*/
fileTree("$extraModsPrefix-$minecraftVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: '${f.nameWithoutExtension}'. Expected format: 'modName-version.jar'")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod ${f.nameWithoutExtension} detected.")
"modLocalRuntime"("extra-mods:$mod:$version")
}
2023-06-14 05:48:49 -04:00
// tests
2022-06-23 12:47:03 -04:00
testImplementation(project(":Common"))
testImplementation(commonTests)
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
2022-05-31 10:50:46 -04:00
}