summaryrefslogtreecommitdiff
path: root/sharedVariables/src
diff options
context:
space:
mode:
Diffstat (limited to 'sharedVariables/src')
-rw-r--r--sharedVariables/src/EnvFileReader.kt15
-rw-r--r--sharedVariables/src/NoOp.kt9
-rw-r--r--sharedVariables/src/Versions.kt39
3 files changed, 63 insertions, 0 deletions
diff --git a/sharedVariables/src/EnvFileReader.kt b/sharedVariables/src/EnvFileReader.kt
new file mode 100644
index 0000000..95cbe39
--- /dev/null
+++ b/sharedVariables/src/EnvFileReader.kt
@@ -0,0 +1,15 @@
+package moe.nea.sharedbuild
+
+
+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
+} \ No newline at end of file
diff --git a/sharedVariables/src/NoOp.kt b/sharedVariables/src/NoOp.kt
new file mode 100644
index 0000000..e8cd76e
--- /dev/null
+++ b/sharedVariables/src/NoOp.kt
@@ -0,0 +1,9 @@
+package moe.nea.sharedbuild
+
+import org.gradle.api.Plugin
+
+class NoOp : Plugin<Any> {
+ override fun apply(target: Any) {
+
+ }
+} \ No newline at end of file
diff --git a/sharedVariables/src/Versions.kt b/sharedVariables/src/Versions.kt
new file mode 100644
index 0000000..f559d03
--- /dev/null
+++ b/sharedVariables/src/Versions.kt
@@ -0,0 +1,39 @@
+package moe.nea.sharedbuild
+
+private fun yarn(version: String): String =
+ "net.fabricmc:yarn:${version}:v2"
+
+enum class Versions(
+ val projectName: String,
+ val mappingStyle: String,
+ val minecraftVersion: String,
+ val mappingDependency: String,
+ parentName: String?,
+ val forgeDep: String?,
+ val needsPack200: Boolean,
+ val isBridge: Boolean,
+) {
+ MC189("1.8.9", "srg", "1.8.9", "de.oceanlabs.mcp:mcp_stable:22-1.8.9@zip", "MC11404F", "net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9", true, false),
+ MC11404F("1.14.4-forge", "srg", "1.14.4", "de.oceanlabs.mcp:mcp_stable:58-1.14.4@zip", "MC11404", "net.minecraftforge:forge:1.14.4-28.1.113", false, true),
+ MC11404("1.14.4", "yarn", "1.14.4", yarn("1.14.4+build.1"), "MC12006", null, false, true),
+ MC12006("1.20.6", "yarn", "1.20.6", yarn("1.20.6+build.1"), null, null, false, false),
+ ;
+
+ val parent: Versions? by lazy {
+ if (parentName == null) null
+ else Versions.values().find { it.name == parentName }!!
+ }
+
+ val numericMinecraftVersion = run {
+ require(minecraftVersion.count { it == '.' } == 2)
+ val (a, b, c) = minecraftVersion.split(".").map { it.toInt() }
+ a * 10000 + b * 100 + c
+ }
+ val projectPath get() = ":$projectName"
+
+ companion object {
+ init {
+ values().forEach { it.parent }
+ }
+ }
+}