From 438c5ba2b98ba349195906e5ab95bc42807776c5 Mon Sep 17 00:00:00 2001 From: bconlon Date: Sat, 9 Nov 2024 18:44:24 -0800 Subject: [PATCH] build: switch to ModDevGradle --- build.gradle | 71 ++++++++++++++++-------- gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- update.json | 2 +- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 19d6d06..cf62a3e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version "${neogradle_version}" + id 'net.neoforged.moddev' version "${moddevgradle_version}" id 'com.matthewprenger.cursegradle' version '[1.4,1.5)' id 'com.modrinth.minotaur' version '[2,3)' } @@ -21,29 +21,41 @@ base { java.toolchain.languageVersion = JavaLanguageVersion.of(21) -runs { - configureEach { - systemProperty 'forge.logging.markers', 'REGISTRIES' - systemProperty 'forge.logging.console.level', 'debug' +neoForge { + version = project.neo_version - modSource project.sourceSets.main - } + runs { + configureEach { + systemProperty 'forge.logging.markers', 'REGISTRIES' + logLevel = org.slf4j.event.Level.DEBUG + } - client { - systemProperty 'forge.enabledGameTestNamespaces', mod_id - } + client { + client() + systemProperty 'forge.enabledGameTestNamespaces', mod_id + } - server { - systemProperty 'forge.enabledGameTestNamespaces', mod_id - programArgument '--nogui' - } + server { + server() + systemProperty 'forge.enabledGameTestNamespaces', mod_id + programArgument '--nogui' + } + + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', mod_id + } - gameTestServer { - systemProperty 'neoforge.enabledGameTestNamespaces', mod_id + data { + data() + programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath(), '--existing', file('src/generated/resources/').getAbsolutePath() + } } - data { - programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath(), '--existing', file('src/generated/resources/').getAbsolutePath() + mods { + "${mod_id}" { + sourceSet(sourceSets.main) + } } } @@ -51,21 +63,30 @@ sourceSets.main.resources { srcDir 'src/generated/resources' } +processResources { + exclude '.cache/' +} + +configurations { + runtimeClasspath.extendsFrom localRuntime +} + dependencies { - implementation "net.neoforged:neoforge:${project.neo_version}" + } repositories { maven { url = "https://maven.blamejared.com" } } -tasks.withType(ProcessResources).configureEach { +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { var replaceProperties = [ mod_id : mod_id, mod_name : mod_name, mod_version : mod_version, mod_license : mod_license, mod_url : mod_url, + mod_update : mod_update, mod_tracker : mod_tracker, mod_credits : mod_credits, mod_authors : mod_authors, @@ -77,14 +98,16 @@ tasks.withType(ProcessResources).configureEach { loader_version_range : loader_version_range ] inputs.properties replaceProperties - - filesMatching(['META-INF/neoforge.mods.toml']) { - expand replaceProperties - } + expand replaceProperties + from "src/main/templates" + into "build/generated/sources/modMetadata" } +sourceSets.main.resources.srcDir generateModMetadata +neoForge.ideSyncTask generateModMetadata tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation + options.compilerArgs << "-Xmaxerrs" << "9000" } tasks.register('sourceJar', Jar) { diff --git a/gradle.properties b/gradle.properties index 900f84f..49822df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,7 @@ mod_name=Cumulus mod_version=1.1.0 mod_license=LGPL-3.0 mod_url=https://modrinth.com/mod/cumulus +mod_update=https://github.com/The-Aether-Team/Cumulus/raw/1.21.1-develop/update.json mod_tracker=https://github.com/The-Aether-Team/Cumulus/issues mod_credits=The Aether Team; kingbdogz, for the original Main Menu API that this is inspired by mod_authors=bconlon @@ -22,7 +23,7 @@ mod_description=A library for custom menu registration. minecraft_version=1.21.1 minecraft_version_range=[1.21.1,1.21.2) -neogradle_version=7.0.145 +moddevgradle_version=2.0.42-beta neo_version=21.1.47 neo_version_range=[21.1.47,) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02..0d18421 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/update.json b/update.json index 1f3ba55..f8f92d2 100644 --- a/update.json +++ b/update.json @@ -6,6 +6,6 @@ "1.20.1-recommended": "1.20.1-1.0.0-neoforge", "1.20.2-recommended": "1.20.2-1.0.1-neoforge", "1.20.4-recommended": "1.20.4-1.0.1-neoforge", - "1.21-recommended": "1.21-1.0.4-neoforge" + "1.21.1-recommended": "1.21.1-1.1.0-neoforge" } }