zhangyuheng
5a5d7b0bc2
All checks were successful
Java CI-CD with Gradle / build (push) Successful in 14m19s
完善readme文档
107 lines
3.0 KiB
Plaintext
107 lines
3.0 KiB
Plaintext
import io.papermc.paperweight.util.*
|
|
|
|
plugins {
|
|
java
|
|
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
|
id("io.papermc.paperweight.patcher") version "1.5.12"
|
|
}
|
|
|
|
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"))
|
|
}
|
|
patchTasks.register("generatedApi") {
|
|
isBareDirectory = true
|
|
upstreamDirPath = "paper-api-generator/generated"
|
|
patchDir = layout.projectDirectory.dir("patches/generatedApi")
|
|
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register("updateFoliaRef") {
|
|
// 更新 Folia 依赖的最新 commit
|
|
val tempDir = layout.cacheDir("foliaRefLatest")
|
|
val file = "gradle.properties"
|
|
|
|
doFirst {
|
|
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
|
|
|
|
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)
|
|
}
|
|
}
|
|
} |