From 83465705495ef4d9b8e1221c60a6fa85c33f50b2 Mon Sep 17 00:00:00 2001 From: BitHeaven Date: Mon, 27 Jan 2025 10:05:23 +0500 Subject: [PATCH] Update gradle configuration --- build.gradle | 66 +++++++----------------- gradle.properties | 13 ++--- gradle/libs.versions.toml | 23 +++++++++ gradle/wrapper/gradle-wrapper.properties | 8 ++- settings.gradle | 3 +- 5 files changed, 54 insertions(+), 59 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle b/build.gradle index 0d62ce3..7623529 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,17 @@ plugins { - id 'fabric-loom' version '1.7-SNAPSHOT' + alias libs.plugins.fabric.loom + id "io.github.p03w.machete" version "1.+" // automatic jar compressing on build id 'maven-publish' } -version = "${project.mod_version}-${project.minecraft_version}" -group = project.maven_group - base { archivesName = project.archives_base_name } +String buildNumber = System.getenv("RUN_NUMBER") +version = "${mod_version}+${libs.versions.minecraft.get()}" + (buildNumber != null ? "-${buildNumber}" : "") +group = project.maven_group + loom { splitEnvironmentSourceSets() @@ -35,12 +37,13 @@ configurations { 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}" + minecraft libs.minecraft + mappings variantOf(libs.yarn.mappings) { classifier 'v2' } + + modImplementation libs.fabric.loader // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation libs.fabric.version implementation group: 'org.yaml', name: 'snakeyaml', version: '2.3' includedJars group: 'org.yaml', name: 'snakeyaml', version: '2.3' @@ -50,38 +53,22 @@ dependencies { processResources { inputs.property "version", project.version - inputs.property "minecraft_version", project.minecraft_version - inputs.property "loader_version", project.loader_version - filteringCharset "UTF-8" filesMatching("fabric.mod.json") { - expand "version": project.version, - "minecraft_version": project.minecraft_version, - "loader_version": project.loader_version + expand "version": project.version } } -def targetJavaVersion = 21 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" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release.set(targetJavaVersion) - } + it.options.release = 21 } java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // 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.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + +// withSourcesJar() } jar { @@ -94,21 +81,4 @@ jar { it.isDirectory() ? it : zipTree(it) } } -} -// configure the maven publication -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId = project.archives_base_name - from components.java - } - } - - // 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. - } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6075671..0c7f741 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,9 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G -# Fabric Properties -# check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.16.5 + # Mod Properties -mod_version=1.0.1 +mod_version=1.0 maven_group=ru.bitheaven archives_base_name=donpayinteg -# Dependencies -# check this on https://modmuss50.me/fabric.html -fabric_version=0.105.0+1.21.1 + +# Dependencies are managed at gradle/libs.versions.toml \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..b353592 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,23 @@ +# The latest versions are available at https://quiltmc.org/en/usage/latest-versions +[versions] +minecraft = "1.21.4" +yarn_mappings="1.21.4+build.8" + +fabric_loom = "1.9-SNAPSHOT" +# check these on https://modmuss50.me/fabric.html +fabric_loader = "0.16.10" +fabric_version="0.115.0+1.21.4" + +[libraries] +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } + +fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" } +fabric_version = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_version" } +yarn_mappings = { module = "net.fabricmc:yarn", version.ref = "yarn_mappings" } + + +# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". +[bundles] + +[plugins] +fabric_loom = { id = "fabric-loom", version.ref = "fabric_loom" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d8ab51..e2847c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1 +1,7 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index f91a4fe..56266b4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,6 +4,7 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + mavenCentral() gradlePluginPortal() } -} +} \ No newline at end of file