2022-09-24 14:05:47 -04:00
|
|
|
@file:Suppress("UnstableApiUsage")
|
2022-05-31 10:50:46 -04:00
|
|
|
|
2022-09-24 14:05:47 -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
|
2022-09-24 14:05:47 -04:00
|
|
|
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
|
2022-09-24 14:05:47 -04:00
|
|
|
val modId: String by project
|
|
|
|
val modName: String by project
|
2022-05-31 10:50:46 -04:00
|
|
|
|
2022-09-24 14:05:47 -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)
|
|
|
|
}
|
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
loom {
|
|
|
|
shareCaches()
|
|
|
|
silentMojangMappingsLicense()
|
2022-05-31 10:50:46 -04:00
|
|
|
|
|
|
|
runs {
|
2022-09-24 14:05:47 -04:00
|
|
|
named("client") {
|
|
|
|
client()
|
|
|
|
configName = "Forge Client"
|
|
|
|
ideConfigGenerated(true)
|
|
|
|
runDir("run")
|
|
|
|
vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
|
2022-05-31 10:50:46 -04:00
|
|
|
}
|
2022-09-24 14:05:47 -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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
forge {
|
|
|
|
mixinConfig("$modId-common.mixins.json")
|
|
|
|
}
|
2022-05-31 10:50:46 -04:00
|
|
|
|
2022-09-24 14:05:47 -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 {
|
2022-09-24 14:05:47 -04:00
|
|
|
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
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
// required for common kubejs plugin and forge runtime
|
|
|
|
modCompileOnly(modLocalRuntime("dev.latvian.mods:kubejs-forge:$kubejsVersion")!!)
|
2022-07-29 16:45:44 -04:00
|
|
|
|
2022-08-21 13:47:06 -04:00
|
|
|
fileTree("$extraModsDirectory-$minecraftVersion") { include("**/*.jar") }
|
2022-07-29 16:45:44 -04:00
|
|
|
.forEach { f ->
|
2022-09-24 14:05:47 -04:00
|
|
|
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
|
|
|
|
if (sepIndex == -1) {
|
2022-07-29 16:45:44 -04:00
|
|
|
throw IllegalArgumentException("Invalid mod name: ${f.nameWithoutExtension}")
|
|
|
|
}
|
2022-09-24 14:05:47 -04:00
|
|
|
val mod = f.nameWithoutExtension.substring(0, sepIndex)
|
|
|
|
val version = f.nameWithoutExtension.substring(sepIndex + 1)
|
2022-07-29 16:45:44 -04:00
|
|
|
println("Extra mod $mod with version $version detected")
|
2022-09-24 14:05:47 -04:00
|
|
|
modLocalRuntime("$extraModsDirectory:$mod:$version")
|
2022-07-29 16:45:44 -04:00
|
|
|
}
|
2022-05-31 17:19:29 -04:00
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
// JUnit Tests
|
2022-06-23 12:47:03 -04:00
|
|
|
testImplementation(project(":Common"))
|
|
|
|
testImplementation(commonTests)
|
2022-09-24 14:05:47 -04:00
|
|
|
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 {
|
2022-09-24 14:05:47 -04:00
|
|
|
// TODO: test if this is necessary
|
2022-05-31 10:50:46 -04:00
|
|
|
jar {
|
2022-09-24 14:05:47 -04:00
|
|
|
from("LICENSE") {
|
|
|
|
rename { "${it}_${modName}" }
|
|
|
|
}
|
2022-09-06 12:00:29 -04:00
|
|
|
}
|
2022-09-24 14:05:47 -04:00
|
|
|
// TODO: test if this is necessary
|
2022-09-06 12:00:29 -04:00
|
|
|
processResources {
|
|
|
|
from(project(":Common").sourceSets.main.get().resources)
|
2022-09-24 14:05:47 -04:00
|
|
|
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
|
2022-09-24 14:05:47 -04:00
|
|
|
from(components["java"])
|
2022-05-31 10:50:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven("file://${System.getenv("local_maven")}")
|
|
|
|
}
|
|
|
|
}
|