aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src
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/src
downloadveloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.gz
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.bz2
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.zip
Initial commit
Diffstat (limited to 'buildSrc/src')
-rw-r--r--buildSrc/src/FixMixins.kt43
1 files changed, 43 insertions, 0 deletions
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()
+ }
+}