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-04-28 10:46:33 +08:00
|
|
|
id("io.papermc.paperweight.patcher") version "1.5.12"
|
2024-02-26 21:37:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
apply(plugin = "java")
|
|
|
|
|
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
languageVersion.set(JavaLanguageVersion.of(17))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven(paperMavenPublicUrl) {
|
|
|
|
content {
|
|
|
|
onlyForConfigurations(configurations.paperclip.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
remapper("net.fabricmc:tiny-remapper:0.8.10:fat")
|
|
|
|
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
|
|
|
paperclip("io.papermc:paperclip:3.0.3")
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
tasks.withType<JavaCompile>().configureEach {
|
|
|
|
options.encoding = Charsets.UTF_8.name()
|
|
|
|
options.release = 17
|
|
|
|
}
|
|
|
|
tasks.withType<Javadoc> {
|
|
|
|
options.encoding = Charsets.UTF_8.name()
|
|
|
|
}
|
|
|
|
tasks.withType<ProcessResources> {
|
|
|
|
filteringCharset = Charsets.UTF_8.name()
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven(paperMavenPublicUrl)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|