From 9b69eb0d5cb268abbd52350d1e4aabb067f2e010 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 31 May 2024 06:19:52 +0200 Subject: meta: Fix include backup repo task (#1190) --- .../src/main/kotlin/neubs/DownloadBackupRepo.kt | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt (limited to 'buildSrc/src/main/kotlin/neubs') 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 . + */ + +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 + + @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) + } + } + } +} -- cgit