Skip to content

Commit 6240cc1

Browse files
committed
update buildscript
1 parent 9958f0d commit 6240cc1

File tree

2 files changed

+54
-27
lines changed

2 files changed

+54
-27
lines changed

build.gradle

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1656003793falsepattern44
1+
//version: 1656003793falsepattern51
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -124,7 +124,9 @@ propertyDefaultIfUnset("repositoryName", "")
124124
propertyDefaultIfUnset("mavenGroupId", "")
125125
propertyDefaultIfUnset("mavenArtifactId", "")
126126
propertyDefaultIfUnset("hasMixinDeps", false)
127-
propertyDefaultIfUnset("mixinPreinitConfig", "")
127+
propertyDefaultIfUnset("mixinConfigs", "")
128+
propertyDefaultIfUnset("mixinPluginPreInit", "")
129+
propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5")
128130
propertyDefaultIfUnset("remapStubs", false)
129131

130132
propertyDefaultIfUnset("modrinthProjectId", "")
@@ -165,8 +167,8 @@ if(accessTransformersFile) {
165167
}
166168

167169
if(usesMixins.toBoolean()) {
168-
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
169-
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
170+
if(mixinsPackage.isEmpty()) {
171+
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
170172
}
171173

172174
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
@@ -176,12 +178,14 @@ if(usesMixins.toBoolean()) {
176178
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
177179
}
178180

179-
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
180-
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
181-
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
182-
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
183-
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
184-
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
181+
if (!mixinPlugin.isEmpty()) {
182+
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
183+
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
184+
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
185+
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
186+
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
187+
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
188+
}
185189
}
186190
}
187191

@@ -299,15 +303,15 @@ dependencies {
299303
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
300304
annotationProcessor("com.google.guava:guava:24.1.1-jre")
301305
annotationProcessor("com.google.code.gson:gson:2.8.6")
302-
annotationProcessor("org.spongepowered:mixin:0.8.3-gasstation")
303306
annotationProcessor("com.llamalad7:MixinExtras:0.0.12-gasstation")
304-
compile("org.spongepowered:mixin:0.8.3-gasstation")
307+
annotationProcessor("org.spongepowered:mixin:0.8.5-gasstation_3")
308+
compile("org.spongepowered:mixin:0.8.5-gasstation_3")
305309
compile("com.llamalad7:MixinExtras:0.0.12-gasstation")
306-
compile("com.falsepattern:00gasstation-mc1.7.10:0.2.1:dev")
310+
compile("com.falsepattern:00gasstation-mc1.7.10:0.3.4:dev")
307311
} else if(hasMixinDeps.toBoolean()) {
308-
runtime("org.spongepowered:mixin:0.8.3-gasstation")
312+
runtime("org.spongepowered:mixin:0.8.5-gasstation_3")
309313
runtime("com.llamalad7:MixinExtras:0.0.12-gasstation")
310-
runtime("com.falsepattern:00gasstation-mc1.7.10:0.2.1:dev")
314+
runtime("com.falsepattern:00gasstation-mc1.7.10:0.3.4:dev")
311315
}
312316
}
313317

@@ -323,14 +327,14 @@ def mixinSrg = new File(mixinDir, "${mixingConfigRefMap}.srg")
323327
def mixinRefMap = new File(mixinDir, mixingConfigRefMap)
324328

325329
task generateAssets {
326-
if(usesMixins.toBoolean()) {
330+
if(usesMixins.toBoolean() && !mixinPlugin.isEmpty()) {
327331
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
328332
"required": true,
329-
"minVersion": "0.7.11",
333+
"minVersion": "${mixinPluginMinimumVersion}",
330334
"package": "${modGroup}.${mixinsPackage}",
331335
"plugin": "${modGroup}.${mixinPlugin}",
332336
"refmap": "${mixingConfigRefMap}",
333-
"target": "@env(DEFAULT)",
337+
"target": "@env(${mixinPluginPreInit.toBoolean() ? "PREINIT": "DEFAULT"})",
334338
"compatibilityLevel": "JAVA_8"
335339
}
336340
@@ -501,9 +505,16 @@ def getManifestAttributes() {
501505
}
502506

503507
if(usesMixins.toBoolean()) {
508+
String[] configs = [];
509+
if (!mixinPlugin.isEmpty()) {
510+
configs += ["mixins.${modId}.json"];
511+
}
512+
if (!mixinConfigs.isEmpty()) {
513+
configs += [mixinConfigs];
514+
}
504515
manifestAttributes += [
505516
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
506-
"MixinConfigs" : "mixins." + modId + ".json" + (mixinPreinitConfig ? "," + mixinPreinitConfig : ""),
517+
"MixinConfigs" : String.join(",", configs),
507518
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
508519
]
509520
}
@@ -1077,6 +1088,9 @@ def checkPropertyExists(String propertyName) {
10771088
}
10781089

10791090
def propertyDefaultIfUnset(String propertyName, defaultValue) {
1091+
if (!project.hasProperty(propertyName)) {
1092+
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")
1093+
}
10801094
if (!project.hasProperty(propertyName) || project.property(propertyName) == "") {
10811095
project.ext.setProperty(propertyName, defaultValue)
10821096
}

gradle.properties

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ usesMixins = false
138138
hasMixinDeps = false
139139
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
140140
mixinPlugin =
141+
# Whether you want the plugin to be configured as a PREINIT mixin
142+
mixinPluginPreInit = false
143+
# The minimum SpongePowered Mixins version required by the plugin. Internal default is 0.8.5 (GasStation)
144+
mixinPluginMinimumVersion =
141145
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
142146
mixinsPackage =
143-
# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be
144-
# managed by the buildscript, only included.
145-
mixinPreinitConfig =
146-
# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete
147-
# SpongeMixins library using this setting.
148-
# MixinBooterLegacy provides Mixins 0.8.2
149-
# SpongeMixins provides Mixins 0.7.11 on the official version, and Mixins 0.7.12 on the nh version
150-
useObsoleteSpongeMixins = false
147+
# Specify any custom mixin .json configs here. If you have multiple, comma-separate them. If you don't want to load
148+
# any jsons manually, leave this empty. You can use custom configs even if you already have a plugin added.
149+
# note: mixins.<modid>.json is used by the mixinPlugin's autogenerated config. Additionally, the refmap from the mixinsPackage
150+
# is always put into mixins.<modid>.refmap.json.
151+
# example: mixins.foo.json,mixins.bar.json
152+
mixinConfigs =
151153

152154
#endregion mixins
153155

@@ -165,6 +167,17 @@ coreModClass = internal.asm.CoreLoadingPlugin
165167

166168
#endregion core
167169

170+
# Dependency deobfuscation settings (advanced)
171+
#region ddeobf
172+
173+
# These 3 entries specify the location where the SRG mappings should be fetched from. Only set these if you know
174+
# what you're doing. The defaults inside the buildscript should just work without any extra configuration.
175+
remoteMappings =
176+
mappingsChannel =
177+
mappingsVersion =
178+
179+
#endregion ddeobf
180+
168181
# Miscellaneous settings
169182
#region misc
170183

0 commit comments

Comments
 (0)