From 0554f1f0670b4bf944c5cbbcd400d20b91991dda Mon Sep 17 00:00:00 2001 From: Ben Kerllenevich Date: Sun, 13 Jun 2021 08:39:12 -0400 Subject: [PATCH] updating submodules breaks things, switch code back to non-submodule for time being --- Paper | 2 +- build.gradle.kts | 58 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/Paper b/Paper index 76a75fc35..19da14ee0 160000 --- a/Paper +++ b/Paper @@ -1 +1 @@ -Subproject commit 76a75fc35ad59bf0eab753a8c0f149376368cfaa +Subproject commit 19da14ee00f93cc6b3e234162062a818df1f97d2 diff --git a/build.gradle.kts b/build.gradle.kts index cb6970556..8ac05adb3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,19 +52,68 @@ subprojects { } } +/* val paperDir = layout.projectDirectory.dir("Paper") +val paperBranch = "dev/1.17" + val initSubmodules by tasks.registering { + group = "paperweight" + outputs.upToDateWhen { false } doLast { paperDir.asFile.mkdirs() - Git(paperDir)("submodule", "update", "--init", "--recursive").executeOut() + Git(layout.projectDirectory)("submodule", "update", "--init", "--recursive").executeOut() } } +val upstreamUpdate by tasks.registering { + group = "paperweight" + + outputs.upToDateWhen { false } + finalizedBy(cleanUpstreamCaches) + + doLast { + Git(paperDir)("fetch").executeOut() + Git(paperDir)("clean", "-fd").executeOut() + Git(paperDir)("reset", "--hard", "origin/$paperBranch").executeOut() + Git(layout.projectDirectory)("add", "--force", paperDir.asFile.name).executeOut() + Git(layout.projectDirectory)("submodule", "update", "--init", "--recursive").executeOut() + } +} + +val cleanUpstreamCaches by tasks.registering(GradleBuild::class) { + dir = paperDir.asFile + tasks = listOf("cleanCache") +} + +val upstreamCommit by tasks.registering { + group = "paperweight" + + outputs.upToDateWhen { false } + doLast { + val old = Git(layout.projectDirectory)("ls-tree", "HEAD", paperDir.asFile.name).readText() + ?.substringAfter("commit ")?.substringBefore("\t") + val changes = Git(paperDir)("log", "--oneline", "$old...HEAD").readText() + changes ?: run { + println("No changes to commit?") + return@doLast + } + val commitMessage = """ + |Updated Upstream (Paper) + | + |Upstream has released updates that appear to apply and compile correctly. + | + |Paper Changes: + |$changes + """.trimMargin() + Git(layout.projectDirectory)("commit", "-m", commitMessage).executeOut() + } +} +*/ + paperweight { serverProject.set(project(":Purpur-Server")) - /* // this is the code for without submodules in case we ever want to use it usePaperUpstream(providers.gradleProperty("paperRef")) { withPaperPatcher { apiPatchDir.set(layout.projectDirectory.dir("patches/api")) @@ -74,8 +123,8 @@ paperweight { serverOutputDir.set(layout.projectDirectory.dir("Purpur-Server")) } } - */ + /* upstreams { register("paper") { upstreamDataTask { @@ -98,4 +147,5 @@ paperweight { } } } -} \ No newline at end of file + */ +}