2021-05-31 19:50:23 +07:00
|
|
|
import com.matthewprenger.cursegradle.CurseArtifact
|
|
|
|
|
import com.matthewprenger.cursegradle.CurseProject
|
|
|
|
|
import com.matthewprenger.cursegradle.CurseRelation
|
2023-01-29 22:40:13 +07:00
|
|
|
import com.modrinth.minotaur.dependencies.DependencyType
|
|
|
|
|
import com.modrinth.minotaur.dependencies.ModDependency
|
2021-06-06 16:10:30 +07:00
|
|
|
import groovy.json.JsonGenerator
|
|
|
|
|
import groovy.json.JsonSlurper
|
2021-05-31 19:50:23 +07:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
|
|
|
|
|
|
plugins {
|
2023-05-02 22:12:46 -04:00
|
|
|
kotlin("jvm").version("1.8.10")
|
|
|
|
|
kotlin("plugin.serialization").version("1.8.10")
|
2021-05-31 19:50:23 +07:00
|
|
|
|
2023-01-29 22:40:13 +07:00
|
|
|
id("fabric-loom").version("1.1.+")
|
2021-05-31 19:50:23 +07:00
|
|
|
id("com.matthewprenger.cursegradle").version("1.4.0")
|
2023-01-29 22:40:13 +07:00
|
|
|
id("com.modrinth.minotaur").version("2.4.5")
|
2021-05-31 19:50:23 +07:00
|
|
|
id("maven-publish")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val prop = Property()
|
|
|
|
|
val env: Map<String, String> = System.getenv()
|
|
|
|
|
|
|
|
|
|
version = env["MOD_VERSION"] ?: "local"
|
|
|
|
|
|
|
|
|
|
repositories {
|
2022-01-27 22:35:51 +07:00
|
|
|
maven("https://maven.bai.lol")
|
2021-05-31 19:50:23 +07:00
|
|
|
maven("https://maven.shedaniel.me/")
|
2023-02-02 20:05:09 +07:00
|
|
|
maven("https://maven.terraformersmc.com/releases")
|
|
|
|
|
maven("https://maven.blamejared.com/")
|
2024-06-09 22:01:07 -05:00
|
|
|
maven("https://maven.ladysnake.org/releases")
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
|
minecraft("com.mojang:minecraft:${prop["minecraft"]}")
|
|
|
|
|
mappings("net.fabricmc:yarn:${prop["yarn"]}:v2")
|
|
|
|
|
|
|
|
|
|
modImplementation("net.fabricmc:fabric-loader:${prop["fabricLoader"]}")
|
|
|
|
|
|
|
|
|
|
modImplementation("net.fabricmc.fabric-api:fabric-api:${prop["fabricApi"]}")
|
|
|
|
|
modImplementation("net.fabricmc:fabric-language-kotlin:${prop["fabricKotlin"]}")
|
|
|
|
|
|
2023-02-07 00:08:37 +07:00
|
|
|
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${prop["cca"]}")
|
|
|
|
|
modImplementation("dev.emi:trinkets:${prop["trinkets"]}")
|
|
|
|
|
|
2022-01-27 22:35:51 +07:00
|
|
|
modCompileOnly("mcp.mobius.waila:wthit-api:fabric-${prop["wthit"]}")
|
2022-08-12 20:31:55 +07:00
|
|
|
modRuntimeOnly("mcp.mobius.waila:wthit:fabric-${prop["wthit"]}")
|
2023-01-29 22:40:13 +07:00
|
|
|
modRuntimeOnly("lol.bai:badpackets:fabric-${prop["badpackets"]}")
|
2023-02-02 20:05:09 +07:00
|
|
|
|
|
|
|
|
modRuntimeOnly("dev.architectury:architectury-fabric:${prop["architectury"]}")
|
|
|
|
|
|
|
|
|
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${prop["rei"]}")
|
|
|
|
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${prop["rei"]}")
|
|
|
|
|
modCompileOnly("dev.emi:emi:${prop["emi"]}")
|
|
|
|
|
prop["jei"].split("-").also { (mc, jei) ->
|
|
|
|
|
modCompileOnly("mezz.jei:jei-${mc}-fabric:${jei}") { isTransitive = false }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
when (prop["recipeViewer"]) {
|
|
|
|
|
"emi" -> modRuntimeOnly("dev.emi:emi:${prop["emi"]}")
|
|
|
|
|
"rei" -> modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${prop["rei"]}")
|
|
|
|
|
"jei" -> prop["jei"].split("-").also { (mc, jei) ->
|
|
|
|
|
modRuntimeOnly("mezz.jei:jei-${mc}-fabric:${jei}")
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-26 13:44:15 +07:00
|
|
|
}
|
2021-06-05 22:21:26 +07:00
|
|
|
|
2021-09-26 13:44:15 +07:00
|
|
|
sourceSets {
|
|
|
|
|
val main by getting
|
2021-12-16 00:13:10 +07:00
|
|
|
|
|
|
|
|
val devrun by creating
|
|
|
|
|
val datagen by creating
|
|
|
|
|
|
|
|
|
|
listOf(devrun, datagen).forEach {
|
|
|
|
|
it.compileClasspath += main.compileClasspath + main.output
|
|
|
|
|
it.runtimeClasspath += main.runtimeClasspath + main.output
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val generated by creating {
|
2021-12-16 13:14:01 +07:00
|
|
|
compiledBy("runDatagen")
|
2021-12-16 00:13:10 +07:00
|
|
|
resources {
|
2021-12-16 13:14:01 +07:00
|
|
|
srcDir(file("src/generated/output"))
|
2021-12-16 00:13:10 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 13:14:01 +07:00
|
|
|
devrun.apply {
|
|
|
|
|
compileClasspath += generated.output
|
|
|
|
|
runtimeClasspath += generated.output
|
|
|
|
|
}
|
2021-12-16 00:13:10 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loom {
|
|
|
|
|
runs {
|
|
|
|
|
getByName("client") {
|
|
|
|
|
source("devrun")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getByName("server") {
|
|
|
|
|
source("devrun")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
create("datagen") {
|
|
|
|
|
server()
|
|
|
|
|
name("Data Generation")
|
|
|
|
|
vmArgs(
|
|
|
|
|
"-Dfabric-api.datagen",
|
2021-12-16 13:14:01 +07:00
|
|
|
"-Dfabric-api.datagen.output-dir=${file("src/generated/output")}",
|
2021-12-16 00:13:10 +07:00
|
|
|
"-Dfabric-api.datagen.modid=slotlink_datagen"
|
|
|
|
|
)
|
2022-01-19 03:54:10 +01:00
|
|
|
runDir("build/datagen")
|
2021-12-16 00:13:10 +07:00
|
|
|
source("datagen")
|
|
|
|
|
}
|
2021-09-26 13:44:15 +07:00
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
java {
|
2021-12-03 15:10:04 +07:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
|
2021-12-16 13:14:01 +07:00
|
|
|
tasks.getByName("runDatagen") {
|
|
|
|
|
inputs.dir(file("src/datagen"))
|
|
|
|
|
outputs.dir(file("src/generated"))
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 19:50:23 +07:00
|
|
|
tasks.withType<JavaCompile> {
|
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tasks.withType<KotlinCompile> {
|
|
|
|
|
kotlinOptions {
|
2021-12-03 15:10:04 +07:00
|
|
|
jvmTarget = "17"
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 00:13:10 +07:00
|
|
|
tasks.jar {
|
|
|
|
|
from(sourceSets["generated"].output) {
|
2021-12-16 13:14:01 +07:00
|
|
|
exclude("fabric.mod.json")
|
2021-12-16 00:13:10 +07:00
|
|
|
exclude(".cache/**")
|
|
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
|
2021-12-16 13:14:01 +07:00
|
|
|
tasks.getByName("processGeneratedResources") {
|
|
|
|
|
dependsOn("runDatagen")
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 00:13:10 +07:00
|
|
|
tasks.withType<ProcessResources> {
|
2021-05-31 19:50:23 +07:00
|
|
|
inputs.property("version", project.version)
|
|
|
|
|
|
|
|
|
|
filesMatching("fabric.mod.json") {
|
|
|
|
|
expand("version" to project.version)
|
|
|
|
|
}
|
2021-06-06 16:10:30 +07:00
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
|
val slurper = JsonSlurper()
|
|
|
|
|
val json = JsonGenerator.Options()
|
|
|
|
|
.disableUnicodeEscaping()
|
|
|
|
|
.build()
|
|
|
|
|
fileTree(outputs.files.asPath) {
|
|
|
|
|
include("**/*.json")
|
|
|
|
|
forEach {
|
|
|
|
|
val mini = json.toJson(slurper.parse(it, "UTF-8"))
|
|
|
|
|
it.writeText(mini)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curseforge {
|
|
|
|
|
env["CURSEFORGE_API"]?.let { CURSEFORGE_API ->
|
|
|
|
|
apiKey = CURSEFORGE_API
|
|
|
|
|
project(closureOf<CurseProject> {
|
2021-06-06 19:09:47 +07:00
|
|
|
id = prop["cf.projectId"]
|
|
|
|
|
releaseType = prop["cf.releaseType"]
|
2021-05-31 19:50:23 +07:00
|
|
|
|
|
|
|
|
changelogType = "markdown"
|
|
|
|
|
changelog = "https://github.com/badasintended/slotlink/releases/tag/${project.version}"
|
|
|
|
|
|
|
|
|
|
mainArtifact(tasks["remapJar"], closureOf<CurseArtifact> {
|
|
|
|
|
displayName = "[${prop["minecraft"]}] v${project.version}"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
addGameVersion("Fabric")
|
2021-06-06 19:09:47 +07:00
|
|
|
prop["cf.gameVersion"].split(", ").forEach {
|
|
|
|
|
addGameVersion(it)
|
|
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
|
|
|
|
|
relations(closureOf<CurseRelation> {
|
2021-06-06 19:09:47 +07:00
|
|
|
prop["cf.require"].split(", ").forEach {
|
|
|
|
|
requiredDependency(it)
|
|
|
|
|
}
|
|
|
|
|
prop["cf.optional"].split(", ").forEach {
|
|
|
|
|
optionalDependency(it)
|
|
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
})
|
|
|
|
|
|
2021-06-06 19:41:12 +07:00
|
|
|
afterEvaluate {
|
|
|
|
|
uploadTask.dependsOn("build")
|
|
|
|
|
}
|
2021-05-31 19:50:23 +07:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-29 22:40:13 +07:00
|
|
|
modrinth {
|
|
|
|
|
env["MODRINTH_TOKEN"]?.let { MODRINTH_TOKEN ->
|
|
|
|
|
token.set(MODRINTH_TOKEN)
|
2021-06-06 19:09:47 +07:00
|
|
|
|
2023-01-29 22:40:13 +07:00
|
|
|
projectId.set(prop["mr.projectId"])
|
|
|
|
|
versionNumber.set(version.toString())
|
|
|
|
|
versionType.set(prop["mr.releaseType"])
|
|
|
|
|
changelog.set("https://github.com/badasintended/slotlink/releases/tag/${project.version}")
|
2021-06-06 19:09:47 +07:00
|
|
|
|
2023-01-29 22:40:13 +07:00
|
|
|
uploadFile.set(tasks["remapJar"])
|
|
|
|
|
loaders.addAll("fabric", "quilt")
|
|
|
|
|
gameVersions.addAll(prop["mr.gameVersion"].split(", "))
|
|
|
|
|
|
|
|
|
|
prop["mr.require"].split(", ").forEach {
|
|
|
|
|
dependencies.add(ModDependency(it, DependencyType.REQUIRED))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop["mr.optional"].split(", ").forEach {
|
|
|
|
|
dependencies.add(ModDependency(it, DependencyType.OPTIONAL))
|
|
|
|
|
}
|
2021-06-06 19:09:47 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 19:50:23 +07:00
|
|
|
class Property {
|
|
|
|
|
|
|
|
|
|
operator fun get(name: String) = project.property(name).toString()
|
|
|
|
|
|
|
|
|
|
}
|