From 6240cc1726c1e858f81a5beee36ac034aa3f5735 Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Sun, 25 Sep 2022 14:25:32 +0200 Subject: [PATCH] update buildscript --- build.gradle | 52 ++++++++++++++++++++++++++++++----------------- gradle.properties | 29 ++++++++++++++++++-------- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 1a07a46..fb2ebb8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1656003793falsepattern44 +//version: 1656003793falsepattern51 /* DO NOT CHANGE THIS FILE! @@ -124,7 +124,9 @@ propertyDefaultIfUnset("repositoryName", "") propertyDefaultIfUnset("mavenGroupId", "") propertyDefaultIfUnset("mavenArtifactId", "") propertyDefaultIfUnset("hasMixinDeps", false) -propertyDefaultIfUnset("mixinPreinitConfig", "") +propertyDefaultIfUnset("mixinConfigs", "") +propertyDefaultIfUnset("mixinPluginPreInit", "") +propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5") propertyDefaultIfUnset("remapStubs", false) propertyDefaultIfUnset("modrinthProjectId", "") @@ -165,8 +167,8 @@ if(accessTransformersFile) { } if(usesMixins.toBoolean()) { - if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { - throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") + if(mixinsPackage.isEmpty()) { + throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!") } targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") @@ -176,12 +178,14 @@ if(usesMixins.toBoolean()) { throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } - String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" - String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" - String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" - String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt" - if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { - throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) + if (!mixinPlugin.isEmpty()) { + String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt" + if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { + throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) + } } } @@ -299,15 +303,15 @@ dependencies { annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") annotationProcessor("com.google.guava:guava:24.1.1-jre") annotationProcessor("com.google.code.gson:gson:2.8.6") - annotationProcessor("org.spongepowered:mixin:0.8.3-gasstation") annotationProcessor("com.llamalad7:MixinExtras:0.0.12-gasstation") - compile("org.spongepowered:mixin:0.8.3-gasstation") + annotationProcessor("org.spongepowered:mixin:0.8.5-gasstation_3") + compile("org.spongepowered:mixin:0.8.5-gasstation_3") compile("com.llamalad7:MixinExtras:0.0.12-gasstation") - compile("com.falsepattern:00gasstation-mc1.7.10:0.2.1:dev") + compile("com.falsepattern:00gasstation-mc1.7.10:0.3.4:dev") } else if(hasMixinDeps.toBoolean()) { - runtime("org.spongepowered:mixin:0.8.3-gasstation") + runtime("org.spongepowered:mixin:0.8.5-gasstation_3") runtime("com.llamalad7:MixinExtras:0.0.12-gasstation") - runtime("com.falsepattern:00gasstation-mc1.7.10:0.2.1:dev") + runtime("com.falsepattern:00gasstation-mc1.7.10:0.3.4:dev") } } @@ -323,14 +327,14 @@ def mixinSrg = new File(mixinDir, "${mixingConfigRefMap}.srg") def mixinRefMap = new File(mixinDir, mixingConfigRefMap) task generateAssets { - if(usesMixins.toBoolean()) { + if(usesMixins.toBoolean() && !mixinPlugin.isEmpty()) { getFile("/src/main/resources/mixins." + modId + ".json").text = """{ "required": true, - "minVersion": "0.7.11", + "minVersion": "${mixinPluginMinimumVersion}", "package": "${modGroup}.${mixinsPackage}", "plugin": "${modGroup}.${mixinPlugin}", "refmap": "${mixingConfigRefMap}", - "target": "@env(DEFAULT)", + "target": "@env(${mixinPluginPreInit.toBoolean() ? "PREINIT": "DEFAULT"})", "compatibilityLevel": "JAVA_8" } @@ -501,9 +505,16 @@ def getManifestAttributes() { } if(usesMixins.toBoolean()) { + String[] configs = []; + if (!mixinPlugin.isEmpty()) { + configs += ["mixins.${modId}.json"]; + } + if (!mixinConfigs.isEmpty()) { + configs += [mixinConfigs]; + } manifestAttributes += [ "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json" + (mixinPreinitConfig ? "," + mixinPreinitConfig : ""), + "MixinConfigs" : String.join(",", configs), "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean() ] } @@ -1077,6 +1088,9 @@ def checkPropertyExists(String propertyName) { } def propertyDefaultIfUnset(String propertyName, defaultValue) { + if (!project.hasProperty(propertyName)) { + System.err.println("Your gradle.properties is missing the $propertyName entry. It has been automatically set to \"$defaultValue\" as fallback. You can find all properties and their description here: https://github.com/FalsePattern/ExampleMod1.7.10/blob/main/gradle.properties") + } if (!project.hasProperty(propertyName) || project.property(propertyName) == "") { project.ext.setProperty(propertyName, defaultValue) } diff --git a/gradle.properties b/gradle.properties index 03b833a..09a56bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -138,16 +138,18 @@ usesMixins = false hasMixinDeps = false # Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. mixinPlugin = +# Whether you want the plugin to be configured as a PREINIT mixin +mixinPluginPreInit = false +# The minimum SpongePowered Mixins version required by the plugin. Internal default is 0.8.5 (GasStation) +mixinPluginMinimumVersion = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! mixinsPackage = -# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be -# managed by the buildscript, only included. -mixinPreinitConfig = -# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete -# SpongeMixins library using this setting. -# MixinBooterLegacy provides Mixins 0.8.2 -# SpongeMixins provides Mixins 0.7.11 on the official version, and Mixins 0.7.12 on the nh version -useObsoleteSpongeMixins = false +# Specify any custom mixin .json configs here. If you have multiple, comma-separate them. If you don't want to load +# any jsons manually, leave this empty. You can use custom configs even if you already have a plugin added. +# note: mixins..json is used by the mixinPlugin's autogenerated config. Additionally, the refmap from the mixinsPackage +# is always put into mixins..refmap.json. +# example: mixins.foo.json,mixins.bar.json +mixinConfigs = #endregion mixins @@ -165,6 +167,17 @@ coreModClass = internal.asm.CoreLoadingPlugin #endregion core +# Dependency deobfuscation settings (advanced) +#region ddeobf + +# These 3 entries specify the location where the SRG mappings should be fetched from. Only set these if you know +# what you're doing. The defaults inside the buildscript should just work without any extra configuration. +remoteMappings = +mappingsChannel = +mappingsVersion = + +#endregion ddeobf + # Miscellaneous settings #region misc