Update gradle and make the buildscript compatible with architectury-loom 0.10+

This commit is contained in:
Username404 2021-10-26 12:04:34 +02:00
parent 4c486bf852
commit 079ecb341b
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
3 changed files with 27 additions and 8 deletions

View File

@ -1,5 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.modrinth.minotaur.request.VersionType
import net.fabricmc.loom.LoomGradleExtension
import net.fabricmc.loom.LoomGradlePlugin
buildscript {
dependencies {
@ -16,7 +18,7 @@ plugins {
id("architectury-plugin") version "[3.0.100, 3.5["
id("dev.architectury.loom") version (
if (JavaVersion.current() >= JavaVersion.VERSION_16)
"[0.9.0.153, 0.9.1["
"[0.9.0.153, 0.10.2["
else "[0.7.3.152, 0.7.4["
) apply false
id("com.github.ben-manes.versions") version "0.39.0"
@ -54,17 +56,35 @@ subprojects {
lateinit var mappingsDep: Dependency
apply(plugin = "dev.architectury.loom")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
extensions.configure<net.fabricmc.loom.LoomGradleExtension>("loom") {
extensions.configure<LoomGradleExtension>("loom") {
mappingsDep = layered {
officialMojangMappings().crane("dev.architectury:crane:${rootProject.architectury.minecraft}+build.+")
officialMojangMappings().parchment("org.parchmentmc.data:parchment-${rootProject.architectury.minecraft}:2021.10.17")
}
silentMojangMappingsLicense()
mixinConfig("snowygui-${project.name}.mixins.json")
refmapName = "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
with(javaClass) {
if (LoomGradlePlugin.LOOM_VERSION.run {
val numberPos = indexOf('.') + 1
substring(numberPos, indexOf('.', numberPos))
}.toDouble() < 10) {
getDeclaredMethod("setRefmapName", String::class.java).invoke(this@configure, refmap)
getDeclaredMethod("mixinConfig", String::class.java).invoke(this@configure, "snowygui-${project.name}.mixins.json")
} else {
getDeclaredMethod("getMixin").invoke(this@configure).run {
javaClass.getDeclaredMethod("getDefaultRefmapName").invoke(this).let { refmapProperty ->
refmapProperty.javaClass.getDeclaredMethod("set", Any::class.java).invoke(refmapProperty, refmap)
}
}
}
}
}
apply(plugin = "com.github.johnrengelman.shadow")
val shadowC by configurations.creating
repositories { maven(url = "https://jitpack.io"); mavenCentral() }
repositories {
maven(url = "https://jitpack.io"); mavenCentral()
maven(url = "https://maven.parchmentmc.org")
}
dependencies {
implementation("$kotlinX:kotlinx-coroutines-jdk8:${rootProject.property("kotlin_coroutines_version")}")
implementation("$kotlinX:kotlinx-serialization-core:$serializationVer")

View File

@ -11,7 +11,6 @@ dependencies {
add("developmentForge", project(path = ":common")) { isTransitive = false }
shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
}; loom {
useFabricMixin = true
if (JavaVersion.current().isJava9Compatible) {
runs {
val args: MutableList<String> = mutableListOf("-Dfml.earlyprogresswindow=false")

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists