almostunified/Forge/build.gradle.kts

132 lines
4.2 KiB
Text
Raw Normal View History

@file:Suppress("UnstableApiUsage")
2022-05-31 10:50:46 -04:00
val junitVersion: String by project
val extraModsDirectory: String by project
val forgeRecipeViewer: String by project
2022-05-31 10:50:46 -04:00
val minecraftVersion: String by project
val forgeVersion: String by project
val reiVersion: String by project
val jeiVersion: String by project
val kubejsVersion: String by project
2022-05-31 12:41:30 -04:00
val mappingsChannel: String by project
val mappingsVersion: String by project
val modId: String by project
val modName: String by project
2022-05-31 10:50:46 -04:00
val baseArchiveName = "$modId-forge-$minecraftVersion"
val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output
plugins {
id("dev.architectury.loom") version "0.12.0-SNAPSHOT"
}
2022-05-31 10:50:46 -04:00
base {
archivesName.set(baseArchiveName)
}
loom {
shareCaches()
silentMojangMappingsLicense()
2022-05-31 10:50:46 -04:00
runs {
named("client") {
client()
configName = "Forge Client"
ideConfigGenerated(true)
runDir("run")
vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
2022-05-31 10:50:46 -04:00
}
named("server") {
server()
configName = "Forge Server"
ideConfigGenerated(true)
runDir("run")
vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
2022-05-31 10:50:46 -04:00
}
}
forge {
mixinConfig("$modId-common.mixins.json")
}
2022-05-31 10:50:46 -04:00
mixin {
defaultRefmapName.set("$modId.refmap.json")
}
}
2022-06-23 12:47:03 -04:00
2022-05-31 10:50:46 -04:00
dependencies {
implementation(project(":Common", "namedElements")) { isTransitive = false }
minecraft("com.mojang:minecraft:$minecraftVersion")
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
mappings(loom.layered {
officialMojangMappings()
// TODO: change this when updating to 1.19.2
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
})
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for forge rei plugin | api does not work here!
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") // required for common jei plugin and mixin
// runtime only
when (forgeRecipeViewer) {
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion")
else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer")
}
2022-05-31 10:50:46 -04:00
// required for common kubejs plugin and forge runtime
modCompileOnly(modLocalRuntime("dev.latvian.mods:kubejs-forge:$kubejsVersion")!!)
2022-08-21 13:47:06 -04:00
fileTree("$extraModsDirectory-$minecraftVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: ${f.nameWithoutExtension}")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod $mod with version $version detected")
modLocalRuntime("$extraModsDirectory:$mod:$version")
}
2022-05-31 17:19:29 -04:00
// JUnit 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
}
tasks {
// TODO: test if this is necessary
2022-05-31 10:50:46 -04:00
jar {
from("LICENSE") {
rename { "${it}_${modName}" }
}
2022-09-06 12:00:29 -04:00
}
// TODO: test if this is necessary
2022-09-06 12:00:29 -04:00
processResources {
from(project(":Common").sourceSets.main.get().resources)
inputs.property("version", project.version)
filesMatching("META-INF/mods.toml") {
expand("version" to project.version)
}
}
withType<JavaCompile> {
source(project(":Common").sourceSets.main.get().allSource)
2022-09-06 12:00:29 -04:00
}
2022-06-23 12:47:03 -04:00
}
2022-05-31 10:50:46 -04:00
publishing {
publications {
register("mavenJava", MavenPublication::class) {
artifactId = baseArchiveName
from(components["java"])
2022-05-31 10:50:46 -04:00
}
}
repositories {
maven("file://${System.getenv("local_maven")}")
}
}