From f0ca8b53a7e1ea9b2271fcfa5734d803c97cd5b6 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Sun, 7 Jan 2024 02:24:21 -0600 Subject: [PATCH] gradle --- build.gradle | 164 +++++++++++++---------- gradle.properties | 20 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 9 +- 4 files changed, 114 insertions(+), 81 deletions(-) diff --git a/build.gradle b/build.gradle index af4ef5e..e3b6c12 100644 --- a/build.gradle +++ b/build.gradle @@ -1,104 +1,124 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' - id 'maven-publish' + id "dev.architectury.loom" version "1.3-SNAPSHOT" + id "maven-publish" } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +base { + archivesName = project.archives_base_name +} -archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group -repositories { - flatDir { - dirs 'libs' - } +java { + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 +} + +loom { + // use this if you are using the official mojang mappings + // and want loom to stop warning you about their license + silentMojangMappingsLicense() + + // since loom 0.10, you are **required** to use the + // "forge" block to configure forge-specific features, + // such as the mixinConfigs array or datagen + forge { + // specify the mixin configs used in this mod + // this will be added to the jar manifest as well! + mixinConfigs = [ + "holographic_renders.mixins.json" + ] + + // missing access transformers? + // don't worry, you can still use them! + // note that your AT *MUST* be located at + // src/main/resources/META-INF/accesstransformer.cfg + // to work as there is currently no config option to change this. + // also, any names used in your access transformer will need to be + // in SRG mapped ("func_" / "field_" with MCP class names) to work! + // (both of these things may be subject to change in the future) + } } repositories { - mavenCentral() - maven { url 'https://jitpack.io' } - maven { - name = "CottonMC" - url = "https://server.bbkr.space/artifactory/libs-release" - } + mavenCentral() + maven { url 'https://jitpack.io' } + maven { + name = "CottonMC" + url = "https://server.bbkr.space/artifactory/libs-release" + } } 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}" - - // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + // to change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + forge "net.minecraftforge:forge:${project.forge_version}" - modImplementation "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}" - include "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}" + modImplementation "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}" + include "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}" - modImplementation include("io.github.cottonmc:LibGui:8.1.0+1.20.1") + modImplementation include("io.github.cottonmc:LibGui:8.1.0+1.20.1") - implementation 'com.madgag:animated-gif-lib:1.4' - include 'com.madgag:animated-gif-lib:1.4' + implementation 'com.madgag:animated-gif-lib:1.4' + include 'com.madgag:animated-gif-lib:1.4' } processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } + // define properties that can be used during resource processing + inputs.property "version", project.version + + // this will replace the property "${version}" in your mods.toml + // with the version you've defined in your gradle.properties + filesMatching("META-INF/mods.toml") { + expand "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 - } +tasks.withType(JavaCompile) { + // 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. + options.encoding = "UTF-8" + options.release = 17 } 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() + // 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() } jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } + // add some additional metadata to the jar manifest + manifest { + attributes([ + "Specification-Title" : project.mod_id, + "Specification-Vendor" : project.mod_author, + "Specification-Version" : "1", + "Implementation-Title" : project.name, + "Implementation-Version" : version, + "Implementation-Vendor" : project.mod_author, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } } // 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. - } + publications { + mavenJava(MavenPublication) { + 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. + } } diff --git a/gradle.properties b/gradle.properties index eefaf29..9c9e699 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,27 @@ org.gradle.jvmargs=-Xmx2G org.gradle.daemon=false -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 loader_version=0.15.0 +enabled_platforms=forge + +architectury_version=9.1.12 +fabric_loader_version=0.15.0 +forge_version=1.20.1-47.2.19 -#Fabric api -fabric_version=0.91.0+1.20.1 worldmesher_version=7e6d626 +# "standard" loom installation with some extra features. +loom.platform=forge + +# Base properties +# minecraft version +minecraft_version=1.20.1 +# yarn, latest version can be found on https://fabricmc.net/develop/ +yarn_mappings=1.20.1+build.10 + # Mod Properties mod_version = 1.0.0 maven_group = com.mystic archives_base_name = holographic-renders + mod_id=holographic_renders + mod_author=Mysticpasta1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..59bc51a 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-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index f91a4fe..606cfc1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,10 @@ pluginManagement { + // when using additional gradle plugins like shadow, + // add their repositories to this list! repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } }