DeerFolia/build.gradle.kts

114 lines
3.4 KiB
Plaintext
Raw Normal View History

2024-02-26 21:37:40 +08:00
import io.papermc.paperweight.util.*
plugins {
java
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
2024-06-01 21:55:45 +08:00
id("io.papermc.paperweight.patcher") version "1.7.1"
2024-02-26 21:37:40 +08:00
}
allprojects {
apply(plugin = "java")
java {
toolchain {
2024-06-01 21:55:45 +08:00
languageVersion.set(JavaLanguageVersion.of(21))
2024-02-26 21:37:40 +08:00
}
}
}
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
repositories {
mavenCentral()
maven(paperMavenPublicUrl) {
content {
onlyForConfigurations(configurations.paperclip.name)
}
}
}
dependencies {
2024-06-01 21:55:45 +08:00
remapper("net.fabricmc:tiny-remapper:0.10.2:fat")
decompiler("org.vineflower:vineflower:1.10.1")
2024-02-26 21:37:40 +08:00
paperclip("io.papermc:paperclip:3.0.3")
}
subprojects {
tasks.withType<JavaCompile>().configureEach {
options.encoding = Charsets.UTF_8.name()
2024-06-01 21:55:45 +08:00
options.release = 21
2024-02-26 21:37:40 +08:00
}
tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}
tasks.withType<ProcessResources> {
filteringCharset = Charsets.UTF_8.name()
}
repositories {
mavenCentral()
maven(paperMavenPublicUrl)
2024-05-08 14:12:46 +08:00
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
maven("https://repo.aikar.co/content/groups/aikar")
maven("https://repo.md-5.net/content/repositories/releases/")
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
maven("https://jitpack.io")
maven("https://repo.codemc.io/repository/maven-public/")
2024-02-26 21:37:40 +08:00
}
}
paperweight {
serverProject.set(project(":deer-folia-server"))
remapRepo.set(paperMavenPublicUrl)
decompileRepo.set(paperMavenPublicUrl)
useStandardUpstream("Folia") {
url.set("https://ssl.lunadeer.cn:14446/mirror/Folia.git")
ref.set(providers.gradleProperty("foliaRef"))
withStandardPatcher {
baseName("Folia")
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
apiOutputDir.set(layout.projectDirectory.dir("deer-folia-api"))
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
serverOutputDir.set(layout.projectDirectory.dir("deer-folia-server"))
}
2024-02-26 23:20:14 +08:00
patchTasks.register("generatedApi") {
isBareDirectory = true
upstreamDirPath = "paper-api-generator/generated"
patchDir = layout.projectDirectory.dir("patches/generatedApi")
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
}
2024-02-26 21:37:40 +08:00
}
}
tasks.register("updateFoliaRef") {
// 更新 Folia 依赖的最新 commit
2024-02-26 23:20:14 +08:00
val tempDir = layout.cacheDir("foliaRefLatest")
val file = "gradle.properties"
2024-02-26 21:37:40 +08:00
doFirst {
2024-02-26 23:20:14 +08:00
val foliaLatestCommitJson = layout.cache.resolve("foliaLatestCommit.json")
download.get().download("https://ssl.lunadeer.cn:14446/api/v1/repos/mirror/Folia/commits?sha=master", foliaLatestCommitJson)
val foliaLatestCommit = gson.fromJson<paper.libs.com.google.gson.JsonArray>(foliaLatestCommitJson).get(0).asJsonObject.get("sha").asString
2024-02-26 21:37:40 +08:00
copy {
from(file)
into(tempDir)
filter { line: String ->
line.replace("foliaRef = .*".toRegex(), "foliaRef = $foliaLatestCommit")
}
}
}
doLast {
copy {
from(tempDir.file("gradle.properties"))
into(project.file(file).parent)
}
}
}