Handle loom 0.9 when doing reflection in the build.gradle.kts file

This commit is contained in:
Username404 2021-10-27 14:20:25 +02:00
parent dbe6390fb4
commit b275be425c
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 6 additions and 4 deletions

View File

@ -62,13 +62,15 @@ subprojects {
} }
silentMojangMappingsLicense() silentMojangMappingsLicense()
val refmap = "snowygui-${project.name}-refmap.json" 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) { with(javaClass) {
if (LoomGradlePlugin.LOOM_VERSION.run { val loomMajorRelease = LoomGradlePlugin.LOOM_VERSION.run {
val numberPos = indexOf('.') + 1 val numberPos = indexOf('.') + 1
substring(numberPos, indexOf('.', numberPos)) substring(numberPos, indexOf('.', numberPos))
}.toShort() < 10) { }.toShort()
getField("refmapName").set(this@configure, refmap) 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<String>::class.java).invoke(this@configure, arrayOf("snowygui-${project.name}.mixins.json")) getMethod("mixinConfig", Array<String>::class.java).invoke(this@configure, arrayOf("snowygui-${project.name}.mixins.json"))
} else { } else {
getDeclaredMethod("getMixin").invoke(this@configure).run { getDeclaredMethod("getMixin").invoke(this@configure).run {