2022-09-24 14:05:47 -04:00
|
|
|
@file:Suppress("UnstableApiUsage")
|
2022-05-31 10:50:46 -04:00
|
|
|
|
2022-10-17 14:57:09 -04:00
|
|
|
val modId: String by project
|
|
|
|
val modName: String by project
|
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-05-31 10:50:46 -04:00
|
|
|
|
2022-10-17 14:57:09 -04:00
|
|
|
val baseArchiveName = "$modId-forge"
|
2022-09-24 14:05:47 -04:00
|
|
|
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 {
|
|
|
|
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-27 12:10:51 -04:00
|
|
|
compileOnly(project(":Common", "namedElements")) { isTransitive = false }
|
2022-09-24 14:05:47 -04:00
|
|
|
|
2022-10-17 14:57:09 -04:00
|
|
|
compileOnly("com.google.auto.service:auto-service:1.0.1")
|
|
|
|
annotationProcessor("com.google.auto.service:auto-service:1.0.1")
|
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
minecraft("com.mojang:minecraft:$minecraftVersion")
|
|
|
|
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
|
|
|
mappings(loom.layered {
|
|
|
|
officialMojangMappings()
|
2022-10-17 14:57:09 -04:00
|
|
|
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion:$mappingsVersion@zip")
|
2022-09-24 14:05:47 -04:00
|
|
|
})
|
|
|
|
|
2022-10-17 14:57:09 -04:00
|
|
|
// required for common rei plugin | api does not work here
|
|
|
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
|
|
|
|
// required for common jei plugin and mixin, transitivity is off because it breaks the forge runtime
|
|
|
|
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
|
|
|
|
|
2022-09-24 14:05:47 -04:00
|
|
|
// runtime only
|
|
|
|
when (forgeRecipeViewer) {
|
|
|
|
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
|
2022-10-17 14:57:09 -04:00
|
|
|
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
|
2022-09-24 14:05:47 -04:00
|
|
|
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-06 12:00:29 -04:00
|
|
|
processResources {
|
|
|
|
from(project(":Common").sourceSets.main.get().resources)
|
2022-09-24 14:05:47 -04:00
|
|
|
}
|
|
|
|
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")}")
|
|
|
|
}
|
|
|
|
}
|