From 5ba7f99326a6c0c9364fe008ec8ac9fdea3782a1 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Tue, 14 Jan 2025 21:25:33 +0000 Subject: [PATCH] Add back inputs on processResources I kinda thought that Gradle would be smart enough to know that these were input (given they're passed to expand), but apparently not :/. --- .../src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt | 5 +++++ projects/core/build.gradle.kts | 2 ++ projects/fabric/build.gradle.kts | 2 ++ projects/forge/build.gradle.kts | 3 +++ 4 files changed, 12 insertions(+) diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt index 7f73f04fa..871514e70 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt @@ -33,6 +33,10 @@ import java.net.URI import java.util.regex.Pattern abstract class CCTweakedExtension(private val project: Project) { + /** Get the hash of the latest git commit. */ + val gitHash: Provider = + gitProvider("", listOf("rev-parse", "HEAD")) { it.trim() } + /** Get the current git branch. */ val gitBranch: Provider = gitProvider("", listOf("rev-parse", "--abbrev-ref", "HEAD")) { it.trim() } @@ -164,6 +168,7 @@ abstract class CCTweakedExtension(private val project: Project) { jacoco.applyTo(this) extensions.configure(JacocoTaskExtension::class.java) { + includes = listOf("dan200.computercraft.*") excludes = listOf( "dan200.computercraft.mixin.*", // Exclude mixins, as they're not executed at runtime. "dan200.computercraft.shared.Capabilities$*", // Exclude capability tokens, as Forge rewrites them. diff --git a/projects/core/build.gradle.kts b/projects/core/build.gradle.kts index 4655b9e50..5ae2dbe4d 100644 --- a/projects/core/build.gradle.kts +++ b/projects/core/build.gradle.kts @@ -40,6 +40,8 @@ dependencies { } tasks.processResources { + inputs.property("gitHash", cct.gitHash) + var props = mapOf("gitContributors" to cct.gitContributors.get().joinToString("\n")) filesMatching("data/computercraft/lua/rom/help/credits.md") { expand(props) } } diff --git a/projects/fabric/build.gradle.kts b/projects/fabric/build.gradle.kts index 54ec3877d..5a2e41f42 100644 --- a/projects/fabric/build.gradle.kts +++ b/projects/fabric/build.gradle.kts @@ -220,6 +220,8 @@ loom { } tasks.processResources { + inputs.property("modVersion", modVersion) + var props = mapOf("version" to modVersion) filesMatching("fabric.mod.json") { expand(props) } diff --git a/projects/forge/build.gradle.kts b/projects/forge/build.gradle.kts index bfd8ee0fa..f35b97fb2 100644 --- a/projects/forge/build.gradle.kts +++ b/projects/forge/build.gradle.kts @@ -190,6 +190,9 @@ dependencies { // Compile tasks tasks.processResources { + inputs.property("modVersion", modVersion) + inputs.property("forgeVersion", libs.versions.forge) + var props = mapOf( "forgeVersion" to libs.versions.forge.get(), "file" to mapOf("jarVersion" to modVersion),