diff options
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/build.gradle.kts | 27 | ||||
-rw-r--r-- | buildSrc/src/EnvFile.kt | 13 | ||||
-rw-r--r-- | buildSrc/src/InnerJarsUnpacker.kt | 70 | ||||
-rw-r--r-- | buildSrc/src/RepoDownload.kt | 41 | ||||
-rw-r--r-- | buildSrc/src/licenseinfo.kt | 144 | ||||
-rw-r--r-- | buildSrc/src/lookupversion.kt | 25 |
6 files changed, 0 insertions, 320 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 54719bc..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe> -// -// SPDX-License-Identifier: CC0-1.0 - -plugins { - kotlin("jvm") version "2.1.0" - `kotlin-dsl` -} -repositories { - mavenCentral() - maven { - name = "jitpack" - url = uri("https://jitpack.io") - } -} -dependencies { - implementation("com.github.romangraef:neaslicenseextractificator:1.1.0") - implementation("com.google.code.gson:gson:2.10.1") -} - -sourceSets { - main { - kotlin { - srcDir(file("src")) - } - } -} diff --git a/buildSrc/src/EnvFile.kt b/buildSrc/src/EnvFile.kt deleted file mode 100644 index ceec763..0000000 --- a/buildSrc/src/EnvFile.kt +++ /dev/null @@ -1,13 +0,0 @@ - -import java.io.File - -fun parseEnvFile(file: File): Map<String, String> { - if (!file.exists()) return mapOf() - val map = mutableMapOf<String, String>() - for (line in file.readText().lines()) { - if (line.isEmpty() || line.startsWith("#")) continue - val parts = line.split("=", limit = 2) - map[parts[0]] = parts.getOrNull(1) ?: "" - } - return map -} diff --git a/buildSrc/src/InnerJarsUnpacker.kt b/buildSrc/src/InnerJarsUnpacker.kt deleted file mode 100644 index de06467..0000000 --- a/buildSrc/src/InnerJarsUnpacker.kt +++ /dev/null @@ -1,70 +0,0 @@ -import com.google.gson.Gson -import com.google.gson.JsonArray -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import java.io.File -import java.util.zip.ZipInputStream -import org.gradle.api.DefaultTask -import org.gradle.api.file.ConfigurableFileCollection -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.OutputFiles -import org.gradle.api.tasks.TaskAction -import kotlin.io.path.createDirectories -import kotlin.io.path.outputStream - -abstract class InnerJarsUnpacker : DefaultTask() { - @get:InputFiles - abstract val inputJars: ConfigurableFileCollection - - @get:OutputDirectory - abstract val outputDir: DirectoryProperty - - private fun getFabricModJson(inputFile: File): JsonObject { - inputFile.inputStream().use { - val zis = ZipInputStream(it) - while (true) { - val entry = zis.nextEntry ?: error("Failed to find fabric.mod.json") - if (entry.name == "fabric.mod.json") { - return Gson().fromJson(zis.reader(), JsonObject::class.java) - } - } - } - } - - @TaskAction - fun unpack() { - inputJars.forEach { inputFile -> - val fabricModObject = getFabricModJson(inputFile) - val jars = fabricModObject["jars"] as? JsonArray ?: error("No jars to unpack in $inputFile") - val jarPaths = jars.map { - ((it as? JsonObject)?.get("file") as? JsonPrimitive)?.asString - ?: error("Invalid Jar $it in $inputFile") - } - extractJars(inputFile, jarPaths) - } - } - - private fun extractJars(inputFile: File, jarPaths: List<String>) { - val outputFile = outputDir.get().asFile.toPath() - val jarPathSet = jarPaths.toMutableSet() - inputFile.inputStream().use { - val zis = ZipInputStream(it) - while (true) { - val entry = zis.nextEntry ?: break - if (jarPathSet.remove(entry.name)) { - val resolvedPath = outputFile.resolve(entry.name) - resolvedPath.parent.createDirectories() - resolvedPath.outputStream().use { os -> - zis.copyTo(os) - } - } - } - } - if (jarPathSet.isNotEmpty()) { - error("Could not extract all jars: $jarPathSet") - } - } -} diff --git a/buildSrc/src/RepoDownload.kt b/buildSrc/src/RepoDownload.kt deleted file mode 100644 index 42a09b3..0000000 --- a/buildSrc/src/RepoDownload.kt +++ /dev/null @@ -1,41 +0,0 @@ -import java.net.URI -import java.util.zip.ZipInputStream -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.OutputDirectory -import org.gradle.api.tasks.TaskAction - -abstract class RepoDownload : DefaultTask() { - @get:Input - abstract val hash: Property<String> - - @get:OutputDirectory - abstract val outputDirectory: DirectoryProperty - - init { - outputDirectory.convention(project.layout.buildDirectory.dir("extracted-test-repo")) - } - - @TaskAction - fun performDownload() { - val outputDir = outputDirectory.asFile.get().absoluteFile - outputDir.mkdirs() - URI("https://github.com/notEnoughUpdates/notEnoughUpdates-rEPO/archive/${hash.get()}.zip").toURL().openStream() - .let(::ZipInputStream) - .use { zipInput -> - while (true) { - val entry = zipInput.nextEntry ?: break - val destination = outputDir.resolve( - entry.name.substringAfter('/')).absoluteFile - require(outputDir in generateSequence(destination) { it.parentFile }) - if (entry.isDirectory) continue - destination.parentFile.mkdirs() - destination.outputStream().use { output -> - zipInput.copyTo(output) - } - } - } - } -} diff --git a/buildSrc/src/licenseinfo.kt b/buildSrc/src/licenseinfo.kt deleted file mode 100644 index 50e4593..0000000 --- a/buildSrc/src/licenseinfo.kt +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe> -// -// SPDX-License-Identifier: CC0-1.0 - -import moe.nea.licenseextractificator.LicenseExtension - -fun LicenseExtension.addExtraLicenseMatchers() { - solo { - name = "Firmament" - description = "A Hypixel SkyBlock mod" - developer("Linnea Gräf") { - webPresence = "https://nea.moe/" - } - spdxLicense.`GPL-3-0-or-later`() - webPresence = "https://git.nea.moe/nea/Firmament/" - } - match { - if (group == "net.minecraft") useLicense { - name = "Minecraft" - description = "Minecraft - The critically acclaimed video game" - license("All Rights Reserved", "https://www.minecraft.net/en-us/eula") - developer("Mojang") { - webPresence = "https://mojang.com" - } - webPresence = "https://www.minecraft.net/en-us" - } - if (module == "architectury") useLicense { - name = "Architectury API" - description = "An intermediary api aimed at easing development of multiplatform mods." - spdxLicense.`LGPL-3-0-or-later`() - developer("Architectury") { - webPresence = "https://docs.architectury.dev/" - } - webPresence = "https://github.com/architectury/architectury-api" - } - if (module.startsWith("RoughlyEnoughItems")) useLicense { - name = module - description = "Your recipe viewer mod for 1.13+." - spdxLicense.MIT() - developer("Shedaniel") { - webPresence = "https://shedaniel.me/" - } - webPresence = "https://github.com/shedaniel/RoughlyEnoughItems" - } - if (module == "cloth-config") useLicense { - name = "Cloth Config" - description = "Client sided configuration API" - spdxLicense.`LGPL-3-0-or-later`() - developer("Shedaniel") { - webPresence = "https://shedaniel.me/" - } - webPresence = "https://github.com/shedaniel/cloth-config" - } - if (module == "basic-math") useLicense { - name = "Cloth BasicMath" - description = "Basic Math Operations" - spdxLicense.Unlicense() - developer("Shedaniel") { - webPresence = "https://shedaniel.me/" - } - webPresence = "https://github.com/shedaniel/cloth-basic-math" - } - if (module == "fabric-language-kotlin") useLicense { - name = "Fabric Language Kotlin" - description = "Kotlin Language Support for Fabric mods" - webPresence = "https://github.com/FabricMC/fabric-language-kotlin" - spdxLicense.`Apache-2-0`() - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - } - if (group == "com.mojang") useLicense { - name = module - description = "Mojang library packaged by Minecraft" - } - } - module("net.fabricmc", "yarn") { - name = "Yarn" - description = "Libre Minecraft mappings, free to use for everyone. No exceptions." - spdxLicense.`CC0-1-0`() - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - webPresence = "https://github.com/FabricMC/yarn/" - } - module("com.mojang", "datafixerupper") { - name = "DataFixerUpper" - description = - "A set of utilities designed for incremental building, merging and optimization of data transformations." - spdxLicense.MIT() - developer("Mojang") { - webPresence = "https://mojang.com" - } - webPresence = "https://github.com/Mojang/DataFixerUpper" - } - module("com.mojang", "brigadier") { - name = "Brigadier" - description = "Brigadier is a command parser & dispatcher, designed and developed for Minecraft: Java Edition." - spdxLicense.MIT() - developer("Mojang") { - webPresence = "https://mojang.com" - } - webPresence = "https://github.com/Mojang/brigadier" - } - module("net.fabricmc", "tiny-remapper") { - name = "Tiny Remapper" - description = "Tiny JAR remapping tool" - spdxLicense.`LGPL-3-0-or-later`() - webPresence = "https://github.com/FabricMC/tiny-remapper" - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - } - module("net.fabricmc", "sponge-mixin") { - name = "Mixin" - description = "Mixin is a trait/mixin framework for Java using ASM" - spdxLicense.MIT() - webPresence = "https://github.com/FabricMC/mixin" - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - developer("SpongePowered") { - webPresence = "https://spongepowered.org/" - } - } - module("net.fabricmc", "tiny-mappings-parser") { - name = "Tiny Mappings Parser" - webPresence = "https://github.com/fabricMC/tiny-mappings-parser" - description = "Library for parsing .tiny mapping files" - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - spdxLicense.`Apache-2-0`() - } - module("net.fabricmc", "fabric-loader") { - name = "Fabric Loader" - description = " Fabric's mostly-version-independent mod loader." - spdxLicense.`Apache-2-0`() - developer("FabricMC") { - webPresence = "https://fabricmc.net/" - } - webPresence = "https://github.com/FabricMC/fabric-loader/" - } -} diff --git a/buildSrc/src/lookupversion.kt b/buildSrc/src/lookupversion.kt deleted file mode 100644 index 8a7c2de..0000000 --- a/buildSrc/src/lookupversion.kt +++ /dev/null @@ -1,25 +0,0 @@ -fun execString(vararg args: String): String { - val pb = ProcessBuilder(*args) - .redirectOutput(ProcessBuilder.Redirect.PIPE) - .start() - pb.waitFor() - return pb.inputStream.readAllBytes().decodeToString().trim() -} - -private val tag = "([0-9.]+)(?:\\+[^-]*)?".toRegex() -private val tagOffset = "([0-9.]+)(?:\\+.*)?-([0-9]+)-(.+)".toRegex() - -inline fun <T> Regex.useMatcher(string: String, block: (MatchResult) -> T): T? { - return matchEntire(string)?.let(block) -} - -fun getGitTagInfo(mcVersion: String): String { - val str = execString("git", "describe", "--tags", "HEAD") - tag.useMatcher(str) { - return it.groupValues[1] + "+mc$mcVersion" - } - tagOffset.useMatcher(str) { - return it.groupValues[1] + "-dev+mc$mcVersion+" + it.groupValues[3] - } - return "nogitversion+mc$mcVersion" -} |