Merge pull request #26 from PlazmaMC/ench/upstream-task

Upstream Task
This commit is contained in:
IPECTER 이팩터
2023-03-24 10:54:32 +09:00
committed by GitHub

View File

@@ -80,3 +80,35 @@ paperweight {
}
}
}
tasks.register("updateUpstream") {
// Update the purpurRef in gradle.properties to be the latest commit.
val tempDir = layout.cacheDir("purpurRefLatest");
val file = "gradle.properties";
val branch = "ver/1.19.4";
doFirst {
data class GithubCommit(
val sha: String
)
val response = layout.cache.resolve("apiResponse.json");
download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/$branch", response);
val latestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(response)["sha"].asString;
copy {
from(file)
into(tempDir)
filter { line: String ->
line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit")
}
}
}
doLast {
copy {
from(tempDir.file("gradle.properties"))
into(project.file(file).parent)
}
}
}