From a0f43cd35ca11705aa581e0d7ecd94633123525e Mon Sep 17 00:00:00 2001 From: Marcel Konrad Date: Tue, 19 Jul 2022 01:10:20 +0200 Subject: [PATCH] Rework buildscript --- build.gradle | 135 +++++++++++++++----------- gradle.properties | 6 +- settings.gradle | 10 ++ src/main/resources/META-INF/mods.toml | 2 +- 4 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 810ad5c..6759901 100644 --- a/build.gradle +++ b/build.gradle @@ -1,37 +1,28 @@ -import org.gradle.plugins.ide.eclipse.model.AccessRule - -buildscript { - repositories { - maven { - url = 'https://files.minecraftforge.net/maven' - } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } +plugins { + id 'java' + id 'eclipse' + id 'net.minecraftforge.gradle' version '5.1.+' } -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' - -version = "${minecraft_version}-${version}" -archivesBaseName = 'WorldHandler' +version = "${minecraft_version}-${mod_version}" +archivesBaseName = project.name java.toolchain.languageVersion = JavaLanguageVersion.of(17) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { - // The mappings can be changed at any time, and must be in the following format. + // The mappings can be changed at any time and must be in the following format. // Channel: Version: - // snapshot YYYYMMDD Snapshot are built nightly. - // stable # Stables are built at the discretion of the MCP team. - // official MCVersion Official field/method names from Mojang mapping files + // official MCVersion Official field/method names from Mojang mapping files + // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official // - // You must be aware of the Mojang license when using the 'official' mappings. + // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md // - // Use non-default mappings at your own risk. they may not always work. + // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge + // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started + // + // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: 'official', version: minecraft_version // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. @@ -41,14 +32,23 @@ minecraft { runs { client { workingDirectory project.file('run') - taskName 'WorldHandler Client' + taskName project.name + ' Client' // Recommended logging data for a userdev environment - // property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + // property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels // property 'forge.logging.console.level', 'debug' + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + // property 'forge.enabledGameTestNamespaces', "${mod_id}" + mods { worldhandler { source sourceSets.main @@ -58,13 +58,29 @@ minecraft { server { workingDirectory project.file('run') - taskName 'WorldHandler Server' + taskName project.name + ' Server' - // Recommended logging data for a userdev environment - // property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console + // property 'forge.logging.markers', 'REGISTRIES' // property 'forge.logging.console.level', 'debug' + // property 'forge.enabledGameTestNamespaces', 'examplemod' + + mods { + worldhandler { + source sourceSets.main + } + } + } + + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + workingDirectory project.file('run') + taskName project.name + ' GameTestServer' + + // property 'forge.logging.markers', 'REGISTRIES' + // property 'forge.logging.console.level', 'debug' + // property 'forge.enabledGameTestNamespaces', 'examplemod' mods { worldhandler { @@ -75,15 +91,12 @@ minecraft { data { workingDirectory project.file('run') - taskName 'WorldHandler Data' + taskName project.name + ' Data' - // Recommended logging data for a userdev environment - // property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console + // property 'forge.logging.markers', 'REGISTRIES' // property 'forge.logging.console.level', 'debug' - args '--mod', 'worldhandler', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { worldhandler { @@ -94,14 +107,18 @@ minecraft { } } +sourceSets.main.resources { + srcDir 'src/generated/resources' +} + repositories { // Put repositories for dependencies here - // ForgeGradle automatically adds the Forge maven and Maven Central for you - - // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: - // flatDir { - // dir 'libs' - // } + // ForgeGradle automatically adds the Forge maven and Maven Central for you + + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } } dependencies { @@ -110,19 +127,13 @@ dependencies { // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - // You may put jars on which you depend on in ./libs or you may define them like so.. - // compile "some.group:artifact:version:classifier" - // compile "some.group:artifact:version" + // Real mod deobf dependency examples - these get remapped to your current mappings + // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency + // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency + // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency - // Real examples - // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env - // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env - - // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. - // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' - - // These dependencies get remapped to your current MCP mappings - // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' + // Examples using mod jars from ./libs + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html @@ -136,7 +147,7 @@ jar { "Specification-Vendor": "Exopandora", "Specification-Version": "1", "Implementation-Title": project.name, - "Implementation-Version": "${version}", + "Implementation-Version": project.jar.archiveVersion, "Implementation-Vendor": "Exopandora", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "Main-Class": "exopandora.worldhandler.Main" @@ -145,7 +156,17 @@ jar { } processResources { - filesMatching(['mods.toml']) { - expand project.properties + outputs.upToDateWhen { + false } + + from sourceSets.main.resources + + filesMatching(['META-INF/mods.toml']) { + expand project.properties + } +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' } diff --git a/gradle.properties b/gradle.properties index 170cc16..ab1d8c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,10 @@ # WorldHandler -version=3.3 -group=exopandora.worldhandler +mod_id=worldhandler +mod_version=3.3 minecraft_version=1.19 forge_version=41.0.100 +group=exopandora.worldhandler +main_class=exopandora.worldhandler.Main # Gradle org.gradle.jvmargs=-Xmx3G diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..1b4ac05 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + url = 'https://maven.minecraftforge.net/' + } + } +} + +rootProject.name = 'WorldHandler' diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 1e2d4ba..5442769 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -11,7 +11,7 @@ license="GPL v3.0" [[mods]] modId="worldhandler" - version="${minecraft_version}-${version}" + version="${minecraft_version}-${mod_version}" displayName="World Handler" description="The World Handler provides a simple and easy to use graphical user interface for commands. It lets you create powerful and complex sub-commands alongside NBT-structures within seconds."