From b3d6dfb49067a5bde0e55d8ed7e09b42e6f8f9e2 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 6 Sep 2024 10:54:45 +0900 Subject: [PATCH] fix properties expansion --- Common/build.gradle.kts | 15 --------------- Fabric/build.gradle.kts | 31 ------------------------------- Forge/build.gradle.kts | 7 ------- NeoForge/build.gradle.kts | 7 ------- build.gradle.kts | 32 +++++++++++++++++++++++++++++++- 5 files changed, 31 insertions(+), 61 deletions(-) diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts index 3e45b6346..767f5a084 100644 --- a/Common/build.gradle.kts +++ b/Common/build.gradle.kts @@ -13,7 +13,6 @@ val minecraftVersion: String by extra val neoformTimestamp: String by extra val modId: String by extra val modJavaVersion: String by extra -//val modName: String by extra val baseArchivesName = "${modId}-${minecraftVersion}-common" base { @@ -89,20 +88,6 @@ tasks.withType { } } -val modName = providers.gradleProperty("modName") - -tasks.withType { -// val resourceProperties = mapOf("modName" to modName) -// val modName = providers.gradleProperty("modName") -// -// // this will ensure that this task is redone when the properties change. -// inputs.property("modName", modName) - - filesMatching("pack.mcmeta") { - expand(mapOf("modName" to modName)) - } -} - publishing { publications { register("commonJar") { diff --git a/Fabric/build.gradle.kts b/Fabric/build.gradle.kts index 0345b2899..3148e337f 100644 --- a/Fabric/build.gradle.kts +++ b/Fabric/build.gradle.kts @@ -72,37 +72,6 @@ tasks.withType { } } -val resourceProperties: Map = rootProject.ext.get("resourceProperties") as Map - -val githubUrl = providers.gradleProperty("githubUrl") -val modAuthor = providers.gradleProperty("modAuthor") -val modDescription = providers.gradleProperty("modDescription") -val modName = providers.gradleProperty("modName") -val versionProvider = provider { - version -} - -tasks.withType { - -// // this will ensure that this task is redone when the properties change. -// inputs.properties(resourceProperties) - - filesMatching( "fabric.mod.json") { - expand(mapOf( - "curseHomepageUrl" to curseHomepageUrl, - "fabricApiVersion" to fabricApiVersion, - "fabricLoaderVersion" to fabricLoaderVersion, - "githubUrl" to githubUrl, - "modAuthor" to modAuthor, - "modDescription" to modDescription, - "modId" to modId, - "modJavaVersion" to modJavaVersion, - "modName" to modName, - "version" to versionProvider, - )) - } -} - dependencies { minecraft( group = "com.mojang", diff --git a/Forge/build.gradle.kts b/Forge/build.gradle.kts index b893376c8..0f2d19436 100644 --- a/Forge/build.gradle.kts +++ b/Forge/build.gradle.kts @@ -156,13 +156,6 @@ tasks.withType { inputs.files(it.sourceSets.main.get().resources) from(it.sourceSets.main.get().resources) } - - // this will ensure that this task is redone when the properties change. - inputs.properties(resourceProperties) - - filesMatching("META-INF/mods.toml") { - expand(resourceProperties) - } } tasks.jar { diff --git a/NeoForge/build.gradle.kts b/NeoForge/build.gradle.kts index daa4df306..26a6630d7 100644 --- a/NeoForge/build.gradle.kts +++ b/NeoForge/build.gradle.kts @@ -68,13 +68,6 @@ tasks.withType { inputs.files(it.sourceSets.main.get().resources) from(it.sourceSets.main.get().resources) } - - // this will ensure that this task is redone when the properties change. - inputs.properties(resourceProperties) - - filesMatching("META-INF/neoforge.mods.toml") { - expand(resourceProperties) - } } java { diff --git a/build.gradle.kts b/build.gradle.kts index 603a27372..135059c44 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -92,7 +92,12 @@ spotless { } subprojects { - version = stringVersion + //adds the build number to the end of the version string if on a build server + var buildNumber = project.findProperty("BUILD_NUMBER") + if (buildNumber == null) { + buildNumber = "9999" + } + version = "${specificationVersion}.${buildNumber}" group = modGroup tasks.withType { @@ -120,6 +125,31 @@ subprojects { } } + tasks.withType { + val properties = mapOf( + "curseHomepageUrl" to curseHomepageUrl, + "fabricApiVersion" to fabricApiVersion, + "fabricLoaderVersion" to fabricLoaderVersion, + "forgeVersionRange" to forgeVersionRange, + "githubUrl" to githubUrl, + "forgeLoaderVersionRange" to forgeLoaderVersionRange, + "neoforgeVersionRange" to neoforgeVersionRange, + "neoforgeLoaderVersionRange" to neoforgeLoaderVersionRange, + "minecraftVersion" to minecraftVersion, + "minecraftVersionRange" to minecraftVersionRange, + "modAuthor" to modAuthor, + "modDescription" to modDescription, + "modId" to modId, + "modJavaVersion" to modJavaVersion, + "modName" to modName, + "version" to version, + ) + inputs.properties(properties) + filesMatching(listOf("META-INF/mods.toml", "META-INF/neoforge.mods.toml", "pack.mcmeta", "fabric.mod.json")) { + expand(properties) + } + } + // Activate reproducible builds // https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives tasks.withType().configureEach {