diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-31 06:19:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-31 14:19:52 +1000 |
commit | 9b69eb0d5cb268abbd52350d1e4aabb067f2e010 (patch) | |
tree | 02cab3fa34257b5bb92529bbf120bd6bb7cb2552 /buildSrc/src/main | |
parent | 202fa439931f4171f2f53995e63f82da6876e596 (diff) | |
download | NotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.tar.gz NotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.tar.bz2 NotEnoughUpdates-9b69eb0d5cb268abbd52350d1e4aabb067f2e010.zip |
meta: Fix include backup repo task (#1190)
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r-- | buildSrc/src/main/kotlin/neubs/DownloadBackupRepo.kt | 54 |
1 files changed, 54 insertions, 0 deletions
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) + } + } + } +} |