almostunified/Fabric/build.gradle.kts

116 lines
3.9 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 extraModsDirectory: String by project
val fabricRecipeViewer: String by project
2022-05-31 10:50:46 -04:00
val minecraftVersion: String by project
val fabricVersion: String by project
val fabricLoaderVersion: String by project
2022-05-31 17:19:29 -04:00
val reiVersion: String by project
2022-09-16 14:13:01 -04:00
val jeiVersion: String by project
val kubejsVersion: String by project
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-fabric"
2022-05-31 10:50:46 -04:00
plugins {
id("fabric-loom") version "0.12-SNAPSHOT"
2022-05-31 10:50:46 -04:00
}
base {
archivesName.set(baseArchiveName)
2022-05-31 10:50:46 -04:00
}
loom {
runs {
named("client") {
client()
configName = "Fabric Client"
ideConfigGenerated(true)
runDir("run")
2022-09-06 12:00:22 -04:00
vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
2022-05-31 10:50:46 -04:00
}
named("server") {
server()
configName = "Fabric Server"
ideConfigGenerated(true)
runDir("run")
2022-09-06 12:00:22 -04:00
vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
2022-05-31 10:50:46 -04:00
}
}
mixin {
defaultRefmapName.set("$modId.refmap.json")
}
}
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")
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricVersion")
mappings(loom.layered {
officialMojangMappings()
2022-10-17 14:57:09 -04:00
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion:$mappingsVersion@zip")
})
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$reiVersion") // required for common rei plugin
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei plugin
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // don't question this, it's required for compiling
modCompileOnly("mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion") // required for common jei plugin and mixin
2022-10-17 14:57:09 -04:00
// runtime only
when (fabricRecipeViewer) {
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion")
else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer")
}
// required for common kubejs plugin and fabric runtime
modCompileOnly(modLocalRuntime("dev.latvian.mods:kubejs-fabric:$kubejsVersion")!!)
val extraMods = fileTree("$extraModsDirectory-$minecraftVersion") { include("**/*.jar") }
if (extraMods.files.isNotEmpty()) {
// required when running the fabric client with extra mods
modLocalRuntime("teamreborn:energy:2.2.0")
}
extraMods.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 10:50:46 -04:00
2022-09-06 12:00:29 -04:00
tasks {
processResources {
from(project(":Common").sourceSets.main.get().resources)
2022-05-31 10:50:46 -04:00
}
withType<JavaCompile> {
source(project(":Common").sourceSets.main.get().allSource)
}
2022-05-31 10:50:46 -04:00
}
publishing {
publications {
register("mavenJava", MavenPublication::class) {
artifactId = baseArchiveName
from(components["java"])
}
}
repositories {
maven("file://${System.getenv("local_maven")}")
}
}