From 7e347a46cb01e6300622530dfe67131933a2bc07 Mon Sep 17 00:00:00 2001 From: arcade_kappa Date: Sat, 23 May 2026 17:25:31 +0800 Subject: [PATCH 1/5] Update unimined & gradle --- .github/workflows/build.yml | 2 +- .github/workflows/release-to-cf-mr.yml | 2 +- .github/workflows/release.yml | 2 +- build.gradle | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6903d9..21b9119 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: distribution: 'temurin' - uses: gradle/actions/setup-gradle@v6 with: - gradle-version: 9.5.0 + gradle-version: 9.5.1 name: Set up Gradle - name: Add permission run: chmod +x ./gradlew diff --git a/.github/workflows/release-to-cf-mr.yml b/.github/workflows/release-to-cf-mr.yml index 9d8fc54..95fe5bb 100644 --- a/.github/workflows/release-to-cf-mr.yml +++ b/.github/workflows/release-to-cf-mr.yml @@ -22,7 +22,7 @@ jobs: - uses: gradle/actions/setup-gradle@v6 with: - gradle-version: 9.5.0 + gradle-version: 9.5.1 name: Set up Gradle - name: Add permission diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 280d4ea..6c88009 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: distribution: 'temurin' - uses: gradle/actions/setup-gradle@v6 with: - gradle-version: 9.5.0 + gradle-version: 9.5.1 name: Set up Gradle - name: Add permission run: chmod +x ./gradlew diff --git a/build.gradle b/build.gradle index 5d5b8a6..fb521cd 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ plugins { id 'java' id 'java-library' id 'maven-publish' - id 'com.gradleup.shadow' version '9.4.0' + id 'com.gradleup.shadow' version '9.4.1' id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1' - id 'xyz.wagyourtail.unimined' version '1.4.17-kappa' + id 'xyz.wagyourtail.unimined' version '1.4.18-kappa' id 'net.kyori.blossom' version '2.2.0' } @@ -69,7 +69,7 @@ unimined.minecraft { if (propertyBool('use_access_transformer')) { accessTransformer "${rootProject.projectDir}/src/main/resources/${propertyString('access_transformer_locations')}" } - loader "0.5.9-alpha" + loader "0.5.12-alpha" runs.all { args += ['--username', minecraft_username] def extraArgs = propertyString('extra_jvm_args') diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1a70468..5dd3c01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 4a3bc9fc6dc2e0fe5bb711dd6a108b93c457f8f8 Mon Sep 17 00:00:00 2001 From: arcade_kappa Date: Sun, 31 May 2026 22:36:01 +0800 Subject: [PATCH 2/5] Switched to more native property approach --- build.gradle | 101 +++++++++++-------------- gradle.properties | 1 - gradle/scripts/dependencies.gradle | 4 +- gradle/scripts/extra.gradle | 4 +- gradle/scripts/helpers.gradle | 96 ----------------------- gradle/scripts/publishing.gradle | 16 ++-- src/main/resource-templates/mcmod.info | 2 +- 7 files changed, 54 insertions(+), 170 deletions(-) delete mode 100644 gradle/scripts/helpers.gradle diff --git a/build.gradle b/build.gradle index fb521cd..677a923 100644 --- a/build.gradle +++ b/build.gradle @@ -10,39 +10,26 @@ plugins { import org.jetbrains.gradle.ext.Gradle -apply from: 'gradle/scripts/helpers.gradle' - -// Early Assertions -assertProperty 'mod_version' -assertProperty 'root_package' -assertProperty 'mod_id' -assertProperty 'mod_name' - -assertSubProperties 'use_access_transformer', 'access_transformer_locations' -assertSubProperties 'is_coremod', 'coremod_includes_mod', 'coremod_plugin_class_name' -assertSubProperties 'use_asset_mover', 'asset_mover_version' - -setDefaultProperty 'generate_sources_jar', true, false -setDefaultProperty 'generate_javadocs_jar', true, false -setDefaultProperty 'minecraft_username', true, 'Developer' -setDefaultProperty 'extra_jvm_args', false, '' +ext { + //noinspection GroovyAssignabilityCheck + access_transformer_locations = "${mod_id}_at.cfg" +} -version = propertyString('mod_version') -group = propertyString('root_package') +version = mod_version +group = root_package base { - archivesName = propertyString('mod_id') + archivesName = mod_id } - java { toolchain { languageVersion = JavaLanguageVersion.of(25) } - if (propertyBool('generate_sources_jar')) { + if (generate_sources_jar.toBoolean()) { withSourcesJar() } - if (propertyBool('generate_javadocs_jar')) { + if (generate_javadocs_jar.toBoolean()) { withJavadocJar() } } @@ -56,8 +43,9 @@ configurations { runtimeOnly.extendsFrom(modRuntimeOnly) } -String remapTaskName = propertyBool('enable_shadow') ? "remapShadowJar" : "remapJar" +def remapTaskName = enable_shadow.toBoolean() ? "remapShadowJar" : "remapJar" +//noinspection GroovyAssignabilityCheck unimined.minecraft { version "1.12.2" @@ -66,31 +54,31 @@ unimined.minecraft { } cleanroom { - if (propertyBool('use_access_transformer')) { - accessTransformer "${rootProject.projectDir}/src/main/resources/${propertyString('access_transformer_locations')}" + if (use_access_transformer.toBoolean()) { + accessTransformer "${rootProject.projectDir}/src/main/resources/$access_transformer_locations" } loader "0.5.12-alpha" runs.all { args += ['--username', minecraft_username] - def extraArgs = propertyString('extra_jvm_args') + def extraArgs = extra_jvm_args if (extraArgs != null && !extraArgs.trim().isEmpty()) { jvmArgs += extraArgs.split { "\\s+" }.toList() } - if (propertyBool('enable_foundation_debug')) { + if (enable_foundation_debug.toBoolean()) { systemProperty("foundation.dump", "true") systemProperty("foundation.verbose", "true") } - if (propertyBool('is_coremod')) { - systemProperty("fml.coreMods.load", propertyString('coremod_plugin_class_name')) + if (is_coremod.toBoolean()) { + systemProperty("fml.coreMods.load", coremod_plugin_class_name) } return } } defaultRemapJar = false - - String jarTaskName = propertyBool('enable_shadow') ? "shadowJar" : "jar" - + + String jarTaskName = enable_shadow.toBoolean() ? "shadowJar" : "jar" + remap(tasks.named(jarTaskName).get()) { mixinRemap { enableBaseMixin() @@ -106,10 +94,10 @@ unimined.minecraft { } dependencies { - if (propertyBool('use_asset_mover')) { - implementation "com.cleanroommc:assetmover:${propertyString('asset_mover_version')}" + if (use_asset_mover.toBoolean()) { + implementation "com.cleanroommc:assetmover:${asset_mover_version}" } - if (propertyBool('enable_junit_testing')) { + if (enable_junit_testing.toBoolean()) { testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } @@ -125,21 +113,21 @@ sourceSets { main { blossom { javaSources { - property('mod_id', propertyString('mod_id')) - property('mod_name', propertyString('mod_name')) - property('mod_version', propertyString('mod_version')) + property('mod_id', mod_id) + property('mod_name', mod_name) + property('mod_version', mod_version) property('package', "${root_package}.${mod_id}") } resources { - property('mod_id', propertyString('mod_id')) - property('mod_name', propertyString('mod_name')) - property('mod_version', propertyString('mod_version')) - property('mod_description', propertyString('mod_description')) - property('mod_authors', propertyStringList('mod_authors', ',').collect {it.strip()}.join('", "')) - property('mod_credits', propertyString('mod_credits')) - property('mod_url', propertyString('mod_url')) - property('mod_update_json', propertyString('mod_update_json')) - property('mod_logo_path', propertyString('mod_logo_path')) + property('mod_id', mod_id) + property('mod_name', mod_name) + property('mod_version', mod_version) + property('mod_description', mod_description) + property('mod_authors', mod_authors.toString().split(',').findAll { !it.isBlank() }.collect { "\"${it.strip()}\"" }.join(', ')) + property('mod_credits', mod_credits) + property('mod_url', mod_url) + property('mod_update_json', mod_update_json) + property('mod_logo_path', mod_logo_path) } } } @@ -166,7 +154,7 @@ idea { afterEvaluate { javacAdditionalOptions = '-encoding utf8' moduleJavacAdditionalOptions = [ - (project.name + '.main'): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ') + (project.name + '.main'): tasks.compileJava.options.compilerArgs.collect { "\"${it}\"" }.join(' ') ] } } @@ -174,7 +162,7 @@ idea { } } -if (!propertyBool('enable_shadow')) { +if (!enable_shadow.toBoolean()) { shadowJar.enabled = false } @@ -198,14 +186,14 @@ jar { attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') attribute_map['NonModDeps'] = true } - if (propertyBool('is_coremod')) { - attribute_map['FMLCorePlugin'] = propertyString('coremod_plugin_class_name') - if (propertyBool('coremod_includes_mod')) { + if (is_coremod.toBoolean()) { + attribute_map['FMLCorePlugin'] = coremod_plugin_class_name + if (coremod_includes_mod.toBoolean()) { attribute_map['FMLCorePluginContainsFMLMod'] = true } } - if (propertyBool('use_access_transformer')) { - attribute_map['FMLAT'] = propertyString('access_transformer_locations') + if (use_access_transformer.toBoolean()) { + attribute_map['FMLAT'] = access_transformer_locations } attributes(attribute_map) } @@ -215,6 +203,7 @@ jar { shadowJar { + //noinspection GroovyAssignabilityCheck,GroovyAccessibility configurations = [project.configurations.shadow] archiveClassifier = "shadow" } @@ -230,7 +219,7 @@ tasks.named(remapTaskName).configure { } compileTestJava { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_25 } test { @@ -238,7 +227,7 @@ test { javaLauncher.set(javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }) - if (propertyBool('show_testing_output')) { + if (show_testing_output.toBoolean()) { testLogging { showStandardStreams = true } diff --git a/gradle.properties b/gradle.properties index 42d25ef..d5d6f8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -58,7 +58,6 @@ maven_url = # If multiple locations are stated, use spaces as the delimiter # WARNING: Use MCP name in AT file. Unimined will remap it to srg name when building. use_access_transformer = true -access_transformer_locations = ${mod_id}_at.cfg # Coremods # The most powerful way to change java classes at runtime, it is however very primitive with little documentation. diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 27ddce2..ab27c7f 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -1,5 +1,3 @@ -apply from: 'gradle/scripts/helpers.gradle' - repositories { // Other repositories described by default: // CleanroomMC: https://maven.cleanroommc.com @@ -21,7 +19,7 @@ repositories { dependencies { compileOnly "com.cleanroommc:sponge-mixin:0.20.13+mixin.0.8.7" - if (propertyBool('enable_lwjglx')) { + if (enable_lwjglx.toBoolean()) { compileOnly "com.cleanroommc:lwjglx:1.0.0" } diff --git a/gradle/scripts/extra.gradle b/gradle/scripts/extra.gradle index a44cb8e..106911e 100644 --- a/gradle/scripts/extra.gradle +++ b/gradle/scripts/extra.gradle @@ -1,5 +1,5 @@ // You may write any gradle buildscript component in this file // This file is automatically applied after build.gradle + dependencies.gradle is ran -// If you wish to use the default helper methods, uncomment the line below -// apply from: 'gradle/scripts/helpers.gradle' +// Helper methods (assertProperty, assertSubProperties, setDefaultProperty) are +// defined directly in build.gradle's script scope and exported via ext. diff --git a/gradle/scripts/helpers.gradle b/gradle/scripts/helpers.gradle deleted file mode 100644 index fd0e96f..0000000 --- a/gradle/scripts/helpers.gradle +++ /dev/null @@ -1,96 +0,0 @@ -import groovy.text.SimpleTemplateEngine -import org.codehaus.groovy.runtime.MethodClosure - -ext.propertyString = this.&propertyString as MethodClosure -ext.propertyBool = this.&propertyBool as MethodClosure -ext.propertyStringList = this.&propertyStringList as MethodClosure -ext.interpolate = this.&interpolate as MethodClosure -ext.assertProperty = this.&assertProperty as MethodClosure -ext.assertSubProperties = this.&assertSubProperties as MethodClosure -ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure -ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure - -String propertyString(String key) { - return $property(key).toString() -} - -boolean propertyBool(String key) { - return propertyString(key).toBoolean() -} - -Collection propertyStringList(String key) { - return propertyStringList(key, ' ') -} - -Collection propertyStringList(String key, String delimit) { - return propertyString(key).split(delimit).findAll { !it.isBlank() } -} - -private Object $property(String key) { - def value = project.findProperty(key) - if (value instanceof String) { - return interpolate(value) - } - return value -} - -String interpolate(String value) { - if (value.startsWith('${{') && value.endsWith('}}')) { - value = value.substring(3, value.length() - 2) - Binding newBinding = new Binding(this.binding.getVariables()) - newBinding.setProperty('it', this) - return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) - } - if (value.contains('${')) { - return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() - } - return value -} - -void assertProperty(String propertyName) { - def property = property(propertyName) - if (property == null) { - throw new GradleException("Property ${propertyName} is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property ${propertyName} is empty!") - } -} - -void assertSubProperties(String propertyName, String... subPropertyNames) { - assertProperty(propertyName) - if (propertyBool(propertyName)) { - for (String subPropertyName : subPropertyNames) { - assertProperty(subPropertyName) - } - } -} - -void setDefaultProperty(String propertyName, boolean warn, defaultValue) { - def property = property(propertyName) - def exists = true - if (property == null) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") - } - } else if (property.isEmpty()) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") - } - } - if (!exists) { - project.setProperty(propertyName, defaultValue.toString()) - } -} - -void assertEnvironmentVariable(String propertyName) { - def property = System.getenv(propertyName) - if (property == null) { - throw new GradleException("System Environment Variable $propertyName is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property $propertyName is empty!") - } -} diff --git a/gradle/scripts/publishing.gradle b/gradle/scripts/publishing.gradle index 5167e81..94a8e45 100644 --- a/gradle/scripts/publishing.gradle +++ b/gradle/scripts/publishing.gradle @@ -1,23 +1,17 @@ -apply from: 'gradle/scripts/helpers.gradle' - -setDefaultProperty('publish_to_maven', true, false) - -if (propertyBool('publish_to_maven')) { - assertProperty('maven_name') - assertProperty('maven_url') +if (publish_to_maven.toBoolean()) { publishing { repositories { maven { - name propertyString('maven_name').replaceAll("\\s", "") - url propertyString('maven_url') + name = maven_name.replaceAll("\\s", "") + url = maven_url credentials(PasswordCredentials) } } publications { mavenJava(MavenPublication) { from components.java // Publish with standard artifacts - setGroupId(propertyString('root_package'))// Publish with root package as maven group - setArtifactId(propertyString('mod_id')) // Publish artifacts with mod id as the artifact id + setGroupId(root_package)// Publish with root package as maven group + setArtifactId(mod_id) // Publish artifacts with mod id as the artifact id // Custom artifact: // If you want to publish a different artifact to the one outputted when building normally diff --git a/src/main/resource-templates/mcmod.info b/src/main/resource-templates/mcmod.info index 64bd562..fbf78e1 100644 --- a/src/main/resource-templates/mcmod.info +++ b/src/main/resource-templates/mcmod.info @@ -4,7 +4,7 @@ "version": "{{ mod_version }}", "mcversion": "1.12.2", "description": "{{ mod_description }}", - "authorList": ["{{ mod_authors }}"], + "authorList": [{{ mod_authors }}], "credits": "{{ mod_credits }}", "url": "{{ mod_url }}", "updateJSON": "{{ mod_update_json }}", From c9113dbaceb0f7dc95304c5e92804a587229c479 Mon Sep 17 00:00:00 2001 From: arcade_kappa Date: Tue, 16 Jun 2026 15:25:46 +0800 Subject: [PATCH 3/5] Update plugin, disable mixin in non-mixin branch --- build.gradle | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 677a923..f40840a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'maven-publish' id 'com.gradleup.shadow' version '9.4.1' id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1' - id 'xyz.wagyourtail.unimined' version '1.4.18-kappa' + id 'xyz.wagyourtail.unimined' version '1.4.23-kappa' id 'net.kyori.blossom' version '2.2.0' } @@ -79,13 +79,7 @@ unimined.minecraft { String jarTaskName = enable_shadow.toBoolean() ? "shadowJar" : "jar" - remap(tasks.named(jarTaskName).get()) { - mixinRemap { - enableBaseMixin() - enableMixinExtra() - disableRefmap() - } - } + remap(tasks.named(jarTaskName).get()) mods { remap(configurations.modCompileOnly) @@ -167,7 +161,7 @@ if (!enable_shadow.toBoolean()) { } compileJava { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_25 } jar { From 251d9660907a75da53c37ca7eb153c54c0971aff Mon Sep 17 00:00:00 2001 From: arcade_kappa Date: Tue, 16 Jun 2026 15:47:05 +0800 Subject: [PATCH 4/5] Update Cleanroom --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f40840a..b3ed9b8 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ unimined.minecraft { if (use_access_transformer.toBoolean()) { accessTransformer "${rootProject.projectDir}/src/main/resources/$access_transformer_locations" } - loader "0.5.12-alpha" + loader "0.5.14-alpha" runs.all { args += ['--username', minecraft_username] def extraArgs = extra_jvm_args From 660c96008d64a71b0b6306b8d44b73c8c2b53e67 Mon Sep 17 00:00:00 2001 From: RuiXuqi <90179819+RuiXuqi@users.noreply.github.com> Date: Thu, 18 Jun 2026 23:20:49 +0800 Subject: [PATCH 5/5] Revert "Switched to more native property approach" This reverts commit 4a3bc9fc6dc2e0fe5bb711dd6a108b93c457f8f8 --- build.gradle | 95 ++++++++++++++----------- gradle.properties | 1 + gradle/scripts/dependencies.gradle | 4 +- gradle/scripts/extra.gradle | 4 +- gradle/scripts/helpers.gradle | 96 ++++++++++++++++++++++++++ gradle/scripts/publishing.gradle | 16 +++-- src/main/resource-templates/mcmod.info | 2 +- 7 files changed, 168 insertions(+), 50 deletions(-) create mode 100644 gradle/scripts/helpers.gradle diff --git a/build.gradle b/build.gradle index b3ed9b8..bace8be 100644 --- a/build.gradle +++ b/build.gradle @@ -10,26 +10,39 @@ plugins { import org.jetbrains.gradle.ext.Gradle -ext { - //noinspection GroovyAssignabilityCheck - access_transformer_locations = "${mod_id}_at.cfg" -} +apply from: 'gradle/scripts/helpers.gradle' + +// Early Assertions +assertProperty 'mod_version' +assertProperty 'root_package' +assertProperty 'mod_id' +assertProperty 'mod_name' + +assertSubProperties 'use_access_transformer', 'access_transformer_locations' +assertSubProperties 'is_coremod', 'coremod_includes_mod', 'coremod_plugin_class_name' +assertSubProperties 'use_asset_mover', 'asset_mover_version' -version = mod_version -group = root_package +setDefaultProperty 'generate_sources_jar', true, false +setDefaultProperty 'generate_javadocs_jar', true, false +setDefaultProperty 'minecraft_username', true, 'Developer' +setDefaultProperty 'extra_jvm_args', false, '' + +version = propertyString('mod_version') +group = propertyString('root_package') base { - archivesName = mod_id + archivesName = propertyString('mod_id') } + java { toolchain { languageVersion = JavaLanguageVersion.of(25) } - if (generate_sources_jar.toBoolean()) { + if (propertyBool('generate_sources_jar')) { withSourcesJar() } - if (generate_javadocs_jar.toBoolean()) { + if (propertyBool('generate_javadocs_jar')) { withJavadocJar() } } @@ -43,7 +56,7 @@ configurations { runtimeOnly.extendsFrom(modRuntimeOnly) } -def remapTaskName = enable_shadow.toBoolean() ? "remapShadowJar" : "remapJar" +String remapTaskName = propertyBool('enable_shadow') ? "remapShadowJar" : "remapJar" //noinspection GroovyAssignabilityCheck unimined.minecraft { @@ -54,22 +67,22 @@ unimined.minecraft { } cleanroom { - if (use_access_transformer.toBoolean()) { - accessTransformer "${rootProject.projectDir}/src/main/resources/$access_transformer_locations" + if (propertyBool('use_access_transformer')) { + accessTransformer "${rootProject.projectDir}/src/main/resources/${propertyString('access_transformer_locations')}" } loader "0.5.14-alpha" runs.all { args += ['--username', minecraft_username] - def extraArgs = extra_jvm_args + def extraArgs = propertyString('extra_jvm_args') if (extraArgs != null && !extraArgs.trim().isEmpty()) { jvmArgs += extraArgs.split { "\\s+" }.toList() } - if (enable_foundation_debug.toBoolean()) { + if (propertyBool('enable_foundation_debug')) { systemProperty("foundation.dump", "true") systemProperty("foundation.verbose", "true") } - if (is_coremod.toBoolean()) { - systemProperty("fml.coreMods.load", coremod_plugin_class_name) + if (propertyBool('is_coremod')) { + systemProperty("fml.coreMods.load", propertyString('coremod_plugin_class_name')) } return } @@ -77,7 +90,7 @@ unimined.minecraft { defaultRemapJar = false - String jarTaskName = enable_shadow.toBoolean() ? "shadowJar" : "jar" + String jarTaskName = propertyBool('enable_shadow') ? "shadowJar" : "jar" remap(tasks.named(jarTaskName).get()) @@ -88,10 +101,10 @@ unimined.minecraft { } dependencies { - if (use_asset_mover.toBoolean()) { - implementation "com.cleanroommc:assetmover:${asset_mover_version}" + if (propertyBool('use_asset_mover')) { + implementation "com.cleanroommc:assetmover:${propertyString('asset_mover_version')}" } - if (enable_junit_testing.toBoolean()) { + if (propertyBool('enable_junit_testing')) { testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } @@ -107,21 +120,21 @@ sourceSets { main { blossom { javaSources { - property('mod_id', mod_id) - property('mod_name', mod_name) - property('mod_version', mod_version) + property('mod_id', propertyString('mod_id')) + property('mod_name', propertyString('mod_name')) + property('mod_version', propertyString('mod_version')) property('package', "${root_package}.${mod_id}") } resources { - property('mod_id', mod_id) - property('mod_name', mod_name) - property('mod_version', mod_version) - property('mod_description', mod_description) - property('mod_authors', mod_authors.toString().split(',').findAll { !it.isBlank() }.collect { "\"${it.strip()}\"" }.join(', ')) - property('mod_credits', mod_credits) - property('mod_url', mod_url) - property('mod_update_json', mod_update_json) - property('mod_logo_path', mod_logo_path) + property('mod_id', propertyString('mod_id')) + property('mod_name', propertyString('mod_name')) + property('mod_version', propertyString('mod_version')) + property('mod_description', propertyString('mod_description')) + property('mod_authors', propertyStringList('mod_authors', ',').collect {it.strip()}.join('", "')) + property('mod_credits', propertyString('mod_credits')) + property('mod_url', propertyString('mod_url')) + property('mod_update_json', propertyString('mod_update_json')) + property('mod_logo_path', propertyString('mod_logo_path')) } } } @@ -148,7 +161,7 @@ idea { afterEvaluate { javacAdditionalOptions = '-encoding utf8' moduleJavacAdditionalOptions = [ - (project.name + '.main'): tasks.compileJava.options.compilerArgs.collect { "\"${it}\"" }.join(' ') + (project.name + '.main'): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ') ] } } @@ -156,7 +169,7 @@ idea { } } -if (!enable_shadow.toBoolean()) { +if (!propertyBool('enable_shadow')) { shadowJar.enabled = false } @@ -180,14 +193,14 @@ jar { attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') attribute_map['NonModDeps'] = true } - if (is_coremod.toBoolean()) { - attribute_map['FMLCorePlugin'] = coremod_plugin_class_name - if (coremod_includes_mod.toBoolean()) { + if (propertyBool('is_coremod')) { + attribute_map['FMLCorePlugin'] = propertyString('coremod_plugin_class_name') + if (propertyBool('coremod_includes_mod')) { attribute_map['FMLCorePluginContainsFMLMod'] = true } } - if (use_access_transformer.toBoolean()) { - attribute_map['FMLAT'] = access_transformer_locations + if (propertyBool('use_access_transformer')) { + attribute_map['FMLAT'] = propertyString('access_transformer_locations') } attributes(attribute_map) } @@ -213,7 +226,7 @@ tasks.named(remapTaskName).configure { } compileTestJava { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_25 + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 } test { @@ -221,7 +234,7 @@ test { javaLauncher.set(javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }) - if (show_testing_output.toBoolean()) { + if (propertyBool('show_testing_output')) { testLogging { showStandardStreams = true } diff --git a/gradle.properties b/gradle.properties index d5d6f8c..42d25ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -58,6 +58,7 @@ maven_url = # If multiple locations are stated, use spaces as the delimiter # WARNING: Use MCP name in AT file. Unimined will remap it to srg name when building. use_access_transformer = true +access_transformer_locations = ${mod_id}_at.cfg # Coremods # The most powerful way to change java classes at runtime, it is however very primitive with little documentation. diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index ab27c7f..27ddce2 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -1,3 +1,5 @@ +apply from: 'gradle/scripts/helpers.gradle' + repositories { // Other repositories described by default: // CleanroomMC: https://maven.cleanroommc.com @@ -19,7 +21,7 @@ repositories { dependencies { compileOnly "com.cleanroommc:sponge-mixin:0.20.13+mixin.0.8.7" - if (enable_lwjglx.toBoolean()) { + if (propertyBool('enable_lwjglx')) { compileOnly "com.cleanroommc:lwjglx:1.0.0" } diff --git a/gradle/scripts/extra.gradle b/gradle/scripts/extra.gradle index 106911e..a44cb8e 100644 --- a/gradle/scripts/extra.gradle +++ b/gradle/scripts/extra.gradle @@ -1,5 +1,5 @@ // You may write any gradle buildscript component in this file // This file is automatically applied after build.gradle + dependencies.gradle is ran -// Helper methods (assertProperty, assertSubProperties, setDefaultProperty) are -// defined directly in build.gradle's script scope and exported via ext. +// If you wish to use the default helper methods, uncomment the line below +// apply from: 'gradle/scripts/helpers.gradle' diff --git a/gradle/scripts/helpers.gradle b/gradle/scripts/helpers.gradle new file mode 100644 index 0000000..fd0e96f --- /dev/null +++ b/gradle/scripts/helpers.gradle @@ -0,0 +1,96 @@ +import groovy.text.SimpleTemplateEngine +import org.codehaus.groovy.runtime.MethodClosure + +ext.propertyString = this.&propertyString as MethodClosure +ext.propertyBool = this.&propertyBool as MethodClosure +ext.propertyStringList = this.&propertyStringList as MethodClosure +ext.interpolate = this.&interpolate as MethodClosure +ext.assertProperty = this.&assertProperty as MethodClosure +ext.assertSubProperties = this.&assertSubProperties as MethodClosure +ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure +ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure + +String propertyString(String key) { + return $property(key).toString() +} + +boolean propertyBool(String key) { + return propertyString(key).toBoolean() +} + +Collection propertyStringList(String key) { + return propertyStringList(key, ' ') +} + +Collection propertyStringList(String key, String delimit) { + return propertyString(key).split(delimit).findAll { !it.isBlank() } +} + +private Object $property(String key) { + def value = project.findProperty(key) + if (value instanceof String) { + return interpolate(value) + } + return value +} + +String interpolate(String value) { + if (value.startsWith('${{') && value.endsWith('}}')) { + value = value.substring(3, value.length() - 2) + Binding newBinding = new Binding(this.binding.getVariables()) + newBinding.setProperty('it', this) + return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) + } + if (value.contains('${')) { + return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() + } + return value +} + +void assertProperty(String propertyName) { + def property = property(propertyName) + if (property == null) { + throw new GradleException("Property ${propertyName} is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property ${propertyName} is empty!") + } +} + +void assertSubProperties(String propertyName, String... subPropertyNames) { + assertProperty(propertyName) + if (propertyBool(propertyName)) { + for (String subPropertyName : subPropertyNames) { + assertProperty(subPropertyName) + } + } +} + +void setDefaultProperty(String propertyName, boolean warn, defaultValue) { + def property = property(propertyName) + def exists = true + if (property == null) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") + } + } else if (property.isEmpty()) { + exists = false + if (warn) { + project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") + } + } + if (!exists) { + project.setProperty(propertyName, defaultValue.toString()) + } +} + +void assertEnvironmentVariable(String propertyName) { + def property = System.getenv(propertyName) + if (property == null) { + throw new GradleException("System Environment Variable $propertyName is not defined!") + } + if (property.isEmpty()) { + throw new GradleException("Property $propertyName is empty!") + } +} diff --git a/gradle/scripts/publishing.gradle b/gradle/scripts/publishing.gradle index 94a8e45..5167e81 100644 --- a/gradle/scripts/publishing.gradle +++ b/gradle/scripts/publishing.gradle @@ -1,17 +1,23 @@ -if (publish_to_maven.toBoolean()) { +apply from: 'gradle/scripts/helpers.gradle' + +setDefaultProperty('publish_to_maven', true, false) + +if (propertyBool('publish_to_maven')) { + assertProperty('maven_name') + assertProperty('maven_url') publishing { repositories { maven { - name = maven_name.replaceAll("\\s", "") - url = maven_url + name propertyString('maven_name').replaceAll("\\s", "") + url propertyString('maven_url') credentials(PasswordCredentials) } } publications { mavenJava(MavenPublication) { from components.java // Publish with standard artifacts - setGroupId(root_package)// Publish with root package as maven group - setArtifactId(mod_id) // Publish artifacts with mod id as the artifact id + setGroupId(propertyString('root_package'))// Publish with root package as maven group + setArtifactId(propertyString('mod_id')) // Publish artifacts with mod id as the artifact id // Custom artifact: // If you want to publish a different artifact to the one outputted when building normally diff --git a/src/main/resource-templates/mcmod.info b/src/main/resource-templates/mcmod.info index fbf78e1..64bd562 100644 --- a/src/main/resource-templates/mcmod.info +++ b/src/main/resource-templates/mcmod.info @@ -4,7 +4,7 @@ "version": "{{ mod_version }}", "mcversion": "1.12.2", "description": "{{ mod_description }}", - "authorList": [{{ mod_authors }}], + "authorList": ["{{ mod_authors }}"], "credits": "{{ mod_credits }}", "url": "{{ mod_url }}", "updateJSON": "{{ mod_update_json }}",