2019-07-11 08:29:43 +08:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
2021-11-14 16:01:06 +08:00
|
|
|
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
2023-09-19 12:20:56 +08:00
|
|
|
import net.fabricmc.loom.configuration.FabricApiExtension
|
2019-07-11 08:29:43 +08:00
|
|
|
import net.fabricmc.loom.task.RemapJarTask
|
2024-04-10 14:18:18 +08:00
|
|
|
import net.fabricmc.loom.task.RunGameTask
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2024-02-18 11:28:02 +08:00
|
|
|
plugins {
|
2024-04-30 08:29:02 +08:00
|
|
|
alias(libs.plugins.fabric.loom)
|
2024-02-18 11:28:02 +08:00
|
|
|
`java-library`
|
2024-04-30 08:29:02 +08:00
|
|
|
id("buildlogic.platform")
|
2020-04-10 10:29:10 +08:00
|
|
|
}
|
|
|
|
|
2024-04-30 08:29:02 +08:00
|
|
|
platform {
|
|
|
|
kind = buildlogic.WorldEditKind.Mod
|
|
|
|
includeClasspath = true
|
|
|
|
}
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2020-06-24 02:55:49 +08:00
|
|
|
val fabricApiConfiguration: Configuration = configurations.create("fabricApi")
|
|
|
|
|
2021-11-14 16:01:06 +08:00
|
|
|
configure<LoomGradleExtensionAPI> {
|
|
|
|
accessWidenerPath.set(project.file("src/main/resources/worldedit.accesswidener"))
|
|
|
|
}
|
|
|
|
|
2024-04-10 14:18:18 +08:00
|
|
|
tasks.withType<RunGameTask>().configureEach {
|
|
|
|
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
|
|
|
|
}
|
|
|
|
|
2020-06-24 02:55:49 +08:00
|
|
|
repositories {
|
2024-07-18 13:00:26 +08:00
|
|
|
afterEvaluate {
|
|
|
|
verifyEngineHubRepositories()
|
2023-06-04 13:40:08 +08:00
|
|
|
}
|
2020-06-24 02:55:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-11 08:29:43 +08:00
|
|
|
dependencies {
|
2020-07-16 09:48:47 +08:00
|
|
|
"api"(project(":worldedit-core"))
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2024-04-29 16:23:07 +08:00
|
|
|
"minecraft"(libs.fabric.minecraft)
|
2021-11-14 16:01:06 +08:00
|
|
|
"mappings"(project.the<LoomGradleExtensionAPI>().officialMojangMappings())
|
2024-04-29 16:23:07 +08:00
|
|
|
"modImplementation"(libs.fabric.loader)
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2020-06-24 02:55:49 +08:00
|
|
|
|
2023-09-19 12:20:56 +08:00
|
|
|
// [1] Load the API dependencies from the fabric mod json...
|
2020-06-26 13:00:37 +08:00
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
val fabricModJson = file("src/main/resources/fabric.mod.json").bufferedReader().use {
|
|
|
|
groovy.json.JsonSlurper().parse(it) as Map<String, Map<String, *>>
|
|
|
|
}
|
|
|
|
val wantedDependencies = (fabricModJson["depends"] ?: error("no depends in fabric.mod.json")).keys
|
|
|
|
.filter { it == "fabric-api-base" || it.contains(Regex("v\\d$")) }
|
2022-03-01 14:55:50 +08:00
|
|
|
.toSet()
|
2023-09-19 12:20:56 +08:00
|
|
|
// [2] Request the matching dependency from fabric-loom
|
2020-06-26 13:00:37 +08:00
|
|
|
for (wantedDependency in wantedDependencies) {
|
2024-04-29 16:23:07 +08:00
|
|
|
val dep = project.the<FabricApiExtension>().module(wantedDependency, libs.versions.fabric.api.get())
|
2023-09-19 12:20:56 +08:00
|
|
|
"include"(dep)
|
|
|
|
"modImplementation"(dep)
|
2019-09-20 09:11:23 +08:00
|
|
|
}
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2021-01-06 04:14:54 +08:00
|
|
|
// No need for this at runtime
|
2024-04-29 16:23:07 +08:00
|
|
|
"modCompileOnly"(libs.fabric.permissions.api)
|
2021-01-06 04:14:54 +08:00
|
|
|
|
2021-11-14 16:01:06 +08:00
|
|
|
// Silence some warnings, since apparently this isn't on the compile classpath like it should be.
|
2024-04-29 16:23:07 +08:00
|
|
|
"compileOnly"(libs.errorprone.annotations)
|
2019-07-11 08:29:43 +08:00
|
|
|
}
|
|
|
|
|
2021-11-14 13:54:21 +08:00
|
|
|
configure<BasePluginExtension> {
|
2024-04-29 16:23:07 +08:00
|
|
|
archivesName.set("${project.name}-mc${libs.fabric.minecraft.get().version}")
|
2019-07-11 08:29:43 +08:00
|
|
|
}
|
2021-11-14 13:54:21 +08:00
|
|
|
|
2021-04-07 04:45:57 +08:00
|
|
|
configure<PublishingExtension> {
|
|
|
|
publications.named<MavenPublication>("maven") {
|
2021-11-14 13:54:21 +08:00
|
|
|
artifactId = the<BasePluginExtension>().archivesName.get()
|
|
|
|
from(components["java"])
|
2021-04-07 04:45:57 +08:00
|
|
|
}
|
|
|
|
}
|
2019-07-11 08:29:43 +08:00
|
|
|
|
|
|
|
tasks.named<Copy>("processResources") {
|
|
|
|
// this will ensure that this task is redone when the versions change.
|
|
|
|
inputs.property("version", project.ext["internalVersion"])
|
2021-05-14 13:01:45 +08:00
|
|
|
filesMatching("fabric.mod.json") {
|
|
|
|
this.expand("version" to project.ext["internalVersion"])
|
2019-07-11 08:29:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named<ShadowJar>("shadowJar") {
|
|
|
|
archiveClassifier.set("dist-dev")
|
|
|
|
dependencies {
|
2019-10-19 15:48:49 +08:00
|
|
|
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
|
2023-08-07 01:52:26 +08:00
|
|
|
relocate("net.royawesome.jlibnoise", "com.sk89q.worldedit.jlibnoise")
|
2019-07-11 08:29:43 +08:00
|
|
|
|
2019-10-19 15:48:49 +08:00
|
|
|
include(dependency("org.antlr:antlr4-runtime"))
|
2023-08-07 01:52:26 +08:00
|
|
|
include(dependency("com.sk89q.lib:jlibnoise"))
|
2019-07-11 08:29:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-20 09:11:23 +08:00
|
|
|
tasks.register<RemapJarTask>("remapShadowJar") {
|
|
|
|
val shadowJar = tasks.getByName<ShadowJar>("shadowJar")
|
|
|
|
dependsOn(shadowJar)
|
2022-03-01 14:55:50 +08:00
|
|
|
inputFile.set(shadowJar.archiveFile)
|
2019-09-20 09:11:23 +08:00
|
|
|
archiveFileName.set(shadowJar.archiveFileName.get().replace(Regex("-dev\\.jar$"), ".jar"))
|
|
|
|
addNestedDependencies.set(true)
|
2019-07-11 08:29:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("assemble").configure {
|
|
|
|
dependsOn("remapShadowJar")
|
|
|
|
}
|