aboutsummaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-30 19:44:32 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-30 19:44:32 +0100
commit0414b87e02e51b51cf9ef0c165e5ed61e5193160 (patch)
tree0d1a0144c44b252dcabc2c1d685a7d2b27e6adee /buildSrc
downloadveloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.gz
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.bz2
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.zip
Initial commit
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/build.gradle.kts18
-rw-r--r--buildSrc/src/FixMixins.kt43
2 files changed, 61 insertions, 0 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
new file mode 100644
index 0000000..6799cc7
--- /dev/null
+++ b/buildSrc/build.gradle.kts
@@ -0,0 +1,18 @@
+
+plugins {
+ `kotlin-dsl`
+ kotlin("jvm")version "1.8.10"
+}
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation("com.google.code.gson:gson:2.10.1")
+}
+
+sourceSets.main {
+ kotlin {
+ srcDir(file("src"))
+ }
+} \ No newline at end of file
diff --git a/buildSrc/src/FixMixins.kt b/buildSrc/src/FixMixins.kt
new file mode 100644
index 0000000..ea5f031
--- /dev/null
+++ b/buildSrc/src/FixMixins.kt
@@ -0,0 +1,43 @@
+import com.google.gson.Gson
+import com.google.gson.JsonArray
+import com.google.gson.JsonObject
+import com.google.gson.JsonPrimitive
+import org.apache.tools.ant.filters.BaseParamFilterReader
+import java.io.File
+import java.io.Reader
+import java.io.StringReader
+
+class MixinFilterReader(reader: Reader) : BaseParamFilterReader() {
+ lateinit var sourceRoots: String
+ val betterReader: StringReader by lazy {
+ StringReader(run {
+ val json = Gson().fromJson(reader.readText(), JsonObject::class.java)
+ val mixinPackage = (json["package"] as JsonPrimitive).asString
+ val allMixins = JsonArray()
+ sourceRoots
+ .split(":")
+ .map { File(it) }
+ .forEach { base ->
+ base.walk()
+ .filter { it.isFile }
+ .forEach {
+ val relativeString = it.toRelativeString(base).replace("\\", "/")
+ if (relativeString.startsWith(mixinPackage.replace(".", "/") + "/")
+ && relativeString.endsWith(".java")
+ && it.readText().contains("@Mixin")
+ )
+ allMixins.add(
+ relativeString.replace("/", ".").dropLast(5).drop(mixinPackage.length + 1)
+ )
+ }
+ }
+ json.add("mixins", allMixins)
+ Gson().toJson(json)
+ })
+
+ }
+
+ override fun read(): Int {
+ return betterReader.read()
+ }
+}