From e39c2eb464240a6d1445ce6ee38ff5b4cb7eb085 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Sat, 20 Jan 2024 12:02:28 +0100 Subject: [PATCH] Clean up gradle building --- build.gradle | 66 +++---------------- gradle.properties | 22 +++---- src/main/resources/fabric.mod.json | 6 +- .../resources/statuseffecttimer.mixins.json | 7 +- 4 files changed, 24 insertions(+), 77 deletions(-) diff --git a/build.gradle b/build.gradle index a096257..b9545f4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,79 +1,33 @@ plugins { + id 'java' id 'fabric-loom' version '1.5-SNAPSHOT' - id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 - -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group - dependencies { - // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}"))) } +version = "${project.mod_version}+${project.minecraft_version}" + processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { - expand "version": project.version + expand "mod_version": project.version } -} -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 17 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion + filesMatching("*.mixins.json") { + expand "java_version": project.java_version } } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() + sourceCompatibility = JavaVersion.toVersion(project.java_version) + targetCompatibility = JavaVersion.toVersion(project.java_version) } -jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } -} - -// configure the maven publication -publishing { - publications { - mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } +tasks.withType(JavaCompile).configureEach { + it.options.release = project.java_version.toInteger() } diff --git a/gradle.properties b/gradle.properties index e21da78..8f9042f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,12 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +# Mod version +mod_version=1.2.0 -# Fabric Properties -# check these on https://fabricmc.net/develop +# Minecraft/Java version +# Also hardcoded in fabric.mod.json and *.mixin.json minecraft_version=1.20 +java_version=17 + +# Fabric versions -- check these on https://fabricmc.net/develop +# Also hardcoded in fabric.mod.json yarn_mappings=1.20+build.1 loader_version=0.15.6 - -# Mod Properties -mod_version = 1.2.0+1.20 -maven_group = se.icus.mag -archives_base_name = statuseffecttimer - -# Dependencies -# Fabric api -fabric_version=0.83.0+1.20 -mixinextras_version=0.2.2 \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fb2429c..a4c5ad4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "statuseffecttimer", - "version": "${version}", + "version": "${mod_version}", "name": "Status Effect Timer", "description": "Overlay a timer on the Vanilla status effect HUD icons", @@ -24,7 +24,7 @@ ], "depends": { - "fabricloader": ">=0.7.4", - "minecraft": "~1.20" + "minecraft": "~1.20", + "fabricloader": ">=0.15.6" } } diff --git a/src/main/resources/statuseffecttimer.mixins.json b/src/main/resources/statuseffecttimer.mixins.json index a19f5d1..d36caec 100644 --- a/src/main/resources/statuseffecttimer.mixins.json +++ b/src/main/resources/statuseffecttimer.mixins.json @@ -1,10 +1,9 @@ { "required": true, - "minVersion": "0.8", - "package": "se.icus.mag.statuseffecttimer", - "compatibilityLevel": "JAVA_8", + "package": "se.icus.mag.statuseffecttimer.mixin", + "compatibilityLevel": "JAVA_17", "client": [ - "mixin.StatusEffectTimerMixin" + "StatusEffectTimerMixin" ], "injectors": { "defaultRequire": 1