diff --git a/build.gradle b/build.gradle deleted file mode 100644 index ae9a2ed..0000000 --- a/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' - id 'maven-publish' -} - -version = mod_version -group = maven_group - -base { - archivesName = archives_base_name -} - -repositories { - maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings - maven { url = "https://maven.parchmentmc.org" } // Parchment mappings - maven { url = "https://api.modrinth.com/maven" } // Create Deco - maven { url = "https://mvn.devos.one/snapshots/" } // Create, Porting Lib, Forge Tags, Milk Lib, Registrate - maven { url = "https://mvn.devos.one/releases/" } // Porting Lib Releases - maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Forge Config API Port - maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes - maven { url = "https://jitpack.io/" } // Fabric ASM - maven { url = "https://maven.tterrag.com/" } // Flywheel -} - -dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${minecraft_version}" - - mappings(loom.layered { - it.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${qm_version}:intermediary-v2") - it.parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip") - it.officialMojangMappings { nameSyntheticMembers = false } - }) - - modImplementation("net.fabricmc:fabric-loader:${fabric_loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") - - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}") - - modImplementation("maven.modrinth:create-deco:2.0.1-1.20.1-fabric") -} - -processResources { - // set up properties for filling into metadata - Map properties = Map.of( - "version", version as String, - "fabric_loader_version", fabric_loader_version, - "fabric_api_version", fabric_api_version, - "minecraft_version", minecraft_version, - ) - properties.forEach((k, v) -> inputs.property(k, v)) - - filesMatching("fabric.mod.json") { - expand properties - } -} - -def targetJavaVersion = 17 -tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release.set(targetJavaVersion) - } -} - -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - withSourcesJar() -} - -jar { - from("LICENSE") { - rename { "${it}_${archives_base_name}"} - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..285f0bd --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,82 @@ +import net.fabricmc.loom.api.LoomGradleExtensionAPI + +plugins { + id("fabric-loom") version "1.5.+" +} + +version = "mod_version"() +group = "maven_group"() +base.archivesName.set("archives_base_name"()) + +repositories { + maven("https://maven.quiltmc.org/repository/release") // Quilt Mappings + maven("https://maven.parchmentmc.org") // Parchment mappings + maven("https://api.modrinth.com/maven") // Create Deco + maven("https://mvn.devos.one/snapshots/") // Create, Porting Lib, Forge Tags, Milk Lib, Registrate + maven("https://mvn.devos.one/releases/") // Porting Lib Releases + maven("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") // Forge Config API Port + maven("https://maven.jamieswhiteshirt.com/libs-release") // Reach Entity Attributes + maven("https://jitpack.io/") // Fabric ASM + maven("https://maven.tterrag.com/") // Flywheel +} + +dependencies { + "minecraft"("com.mojang:minecraft:${"minecraft_version"()}") + + val loom = project.extensions.getByType() + mappings(loom.layered { + mappings("org.quiltmc:quilt-mappings:${"minecraft_version"()}+build.${"qm_version"()}:intermediary-v2") + parchment("org.parchmentmc.data:parchment-${"minecraft_version"()}:${"parchment_version"()}@zip") + officialMojangMappings { nameSyntheticMembers = false } + }) + + modImplementation("net.fabricmc:fabric-loader:${"fabric_loader_version"()}") + modImplementation("net.fabricmc.fabric-api:fabric-api:${"fabric_api_version"()}") + + modImplementation("com.simibubi.create:create-fabric-${"minecraft_version"()}:${"create_version"()}") + + modImplementation("maven.modrinth:create-deco:2.0.1-1.20.1-fabric") +} + +tasks.processResources { + // set up properties for filling into metadata + val properties = mapOf( + "version" to version, + "fabric_loader_version" to "fabric_loader_version"(), + "fabric_api_version" to "fabric_api_version"(), + "minecraft_version" to "minecraft_version"(), + ) + + inputs.properties(properties) + + filesMatching("fabric.mod.json") { + expand(properties) + } +} + +val targetJavaVersion = 17 +tasks.withType().configureEach { + options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + options.release.set(targetJavaVersion) + } +} + +java { + val javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + withSourcesJar() +} + +tasks.jar { + from("LICENSE") { + rename { "${it}_${base.archivesName}"} + } +} + +operator fun String.invoke(): String { + return rootProject.ext[this] as? String + ?: throw IllegalStateException("Property $this is not defined") +} diff --git a/gradle.properties b/gradle.properties index 156c531..fe911b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G # Mod Properties -mod_version = 0.0.1 +mod_version = 0.0.2 maven_group = dev.ithundxr archives_base_name = RailwaysTweaks diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..5f2aee2 --- /dev/null +++ b/release.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +version=$(grep 'mod_version = ' "./gradle.properties" | cut -d'=' -f2 | tr -d ' ') + +git tag -s -a v"$version" -m "$1" + +git push origin v"$version" \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index f91a4fe..0000000 --- a/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -pluginManagement { - repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - gradlePluginPortal() - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..cda21f4 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +pluginManagement { + repositories { + maven("https://maven.fabricmc.net/") + gradlePluginPortal() + } +}