aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-31 06:19:52 +0200
committerGitHub <noreply@github.com>2024-05-31 14:19:52 +1000
commit9b69eb0d5cb268abbd52350d1e4aabb067f2e010 (patch)
tree02cab3fa34257b5bb92529bbf120bd6bb7cb2552
parent202fa439931f4171f2f53995e63f82da6876e596 (diff)
downloadNotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.tar.gz
NotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.tar.bz2
NotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.zip
meta: Fix include backup repo task (#1190)
-rw-r--r--build.gradle.kts23
-rw-r--r--buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt54
2 files changed, 60 insertions, 17 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 64c1a884..ef9ee714 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -18,10 +18,7 @@
*/
-import neubs.CustomSignTask
-import neubs.NEUBuildFlags
-import neubs.applyPublishingInformation
-import neubs.setVersionFromEnvironment
+import neubs.*
import org.apache.commons.lang3.SystemUtils
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.net.URL
@@ -259,18 +256,9 @@ val mixinDependencyCollectionJar by tasks.creating(Zip::class) {
into("neu-mixin-libraries-wrapped")
}
-tasks.register("includeBackupRepo") {
- doLast {
- val url = URL("https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO/archive/refs/heads/prerelease.zip")
- val destinationFolder = project.buildDir.resolve("classes/java/main/assets/notenoughupdates/")
- destinationFolder.mkdirs()
- val destination = destinationFolder.resolve("repo.zip")
- destination.createNewFile()
-
- destination.outputStream().use {
- url.openStream().copyTo(it)
- }
- }
+val includeBackupRepo by tasks.registering(DownloadBackupRepo::class) {
+ this.branch.set("master")
+ this.outputDirectory.set(layout.buildDirectory.dir("downloadedRepo"))
}
@@ -302,6 +290,7 @@ tasks.assemble.get().dependsOn(remapJar)
tasks.processResources {
from(tasks["generateBuildFlags"])
+ from(includeBackupRepo)
filesMatching(listOf("mcmod.info", "fabric.mod.json", "META-INF/mods.toml")) {
expand(
"version" to project.version, "mcversion" to "1.8.9"
@@ -348,4 +337,4 @@ applyPublishingInformation(
"deobf" to tasks.jar,
"all" to tasks.remapJar,
"sources" to tasks["sourcesJar"],
-) \ No newline at end of file
+)
diff --git a/buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt b/buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt
new file mode 100644
index 00000000..afc166bc
--- /dev/null
+++ b/buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2024 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package neubs
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.file.DirectoryProperty
+import org.gradle.api.provider.Property
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.Internal
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.TaskAction
+import java.net.URL
+
+abstract class DownloadBackupRepo : DefaultTask() {
+
+ @get:OutputDirectory
+ abstract val outputDirectory: DirectoryProperty
+
+ @get:Input
+ abstract val branch: Property<String>
+
+ @get:Internal
+ val repoFile get() = outputDirectory.get().asFile.resolve("assets/notenoughupdates/repo.zip")
+
+ @TaskAction
+ fun downloadRepo() {
+ val url =
+ URL("https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO/archive/refs/heads/${branch.get()}.zip")
+ val file = repoFile
+ file.parentFile.mkdirs()
+ file.outputStream().use { out ->
+ url.openStream().use { inp ->
+ inp.copyTo(out)
+ }
+ }
+ }
+}