From b275be425c9d7b919a30add2e311bc4076d14007 Mon Sep 17 00:00:00 2001 From: Username404 Date: Wed, 27 Oct 2021 14:20:25 +0200 Subject: [PATCH] Handle loom 0.9 when doing reflection in the build.gradle.kts file --- build.gradle.kts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2d4bb38..3ef1b90 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,13 +62,15 @@ subprojects { } silentMojangMappingsLicense() val refmap = "snowygui-${project.name}-refmap.json" - // The following is used to make this buildscript compatible with architectury-loom 0.7.3, 0.9.X, 0.10.X and higher versions + // The following is used to make this buildscript compatible with architectury-loom 0.7.3, 0.9.X, 0.10.X and higher versions with(javaClass) { - if (LoomGradlePlugin.LOOM_VERSION.run { + val loomMajorRelease = LoomGradlePlugin.LOOM_VERSION.run { val numberPos = indexOf('.') + 1 substring(numberPos, indexOf('.', numberPos)) - }.toShort() < 10) { - getField("refmapName").set(this@configure, refmap) + }.toShort() + if (loomMajorRelease < 10) { + if (loomMajorRelease < 9) getField("refmapName").set(this@configure, refmap) + else getMethod("setRefmapName", String::class.java).invoke(this@configure, refmap) getMethod("mixinConfig", Array::class.java).invoke(this@configure, arrayOf("snowygui-${project.name}.mixins.json")) } else { getDeclaredMethod("getMixin").invoke(this@configure).run {