almostunified/Forge/build.gradle.kts

128 lines
4.3 KiB
Text
Raw Normal View History

@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
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
2022-05-31 10:50:46 -04:00
2022-10-17 14:57:09 -04:00
val baseArchiveName = "$modId-forge"
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 {
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 {
compileOnly(project(":Common", "namedElements")) { isTransitive = false }
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")
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-10-17 14:57:09 -04:00
// required for common rei plugin | api does not work here
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
// required to disable rei compat layer on jei plugin
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+")
// don't question this, it's required for compiling
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+")
2022-10-17 14:57:09 -04:00
// 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 }
// 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 }
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 {
2022-09-06 12:00:29 -04:00
processResources {
from(project(":Common").sourceSets.main.get().resources)
}
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")}")
}
}