diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts index 767f5a084..5ede6bf88 100644 --- a/Common/build.gradle.kts +++ b/Common/build.gradle.kts @@ -13,6 +13,9 @@ 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 resourceProperties = mapOf("modName" to modName) val baseArchivesName = "${modId}-${minecraftVersion}-common" base { @@ -88,6 +91,15 @@ tasks.withType { } } +tasks.withType { + // this will ensure that this task is redone when the versions change. + inputs.properties(resourceProperties) + + filesMatching("pack.mcmeta") { + expand(resourceProperties) + } +} + publishing { publications { register("commonJar") { diff --git a/Fabric/build.gradle.kts b/Fabric/build.gradle.kts index 3148e337f..1f945a7dc 100644 --- a/Fabric/build.gradle.kts +++ b/Fabric/build.gradle.kts @@ -35,6 +35,8 @@ val modJavaVersion: String by extra val parchmentVersionFabric: String by extra val parchmentMinecraftVersion: String by extra +val resourceProperties: Map by rootProject.extra + // set by ORG_GRADLE_PROJECT_modrinthToken in Jenkinsfile val modrinthToken: String? by project @@ -72,6 +74,15 @@ tasks.withType { } } +tasks.withType { + // this will ensure that this task is redone when the versions change. + inputs.properties(resourceProperties) + + filesMatching( "fabric.mod.json") { + expand(resourceProperties) + } +} + dependencies { minecraft( group = "com.mojang", diff --git a/Forge/build.gradle.kts b/Forge/build.gradle.kts index a55401c86..ae0b8e8a1 100644 --- a/Forge/build.gradle.kts +++ b/Forge/build.gradle.kts @@ -1,4 +1,5 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge +import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent import net.darkhax.curseforgegradle.Constants as CFG_Constants @@ -25,6 +26,8 @@ val modId: String by extra val modJavaVersion: String by extra val parchmentVersionForge: String by extra +val resourceProperties: Map by rootProject.extra + // set by ORG_GRADLE_PROJECT_modrinthToken in Jenkinsfile val modrinthToken: String? by project @@ -148,10 +151,18 @@ tasks.withType().configureEach { } } -tasks.processResources { +tasks.withType { dependencyProjects.forEach { + inputs.files(it.sourceSets.main.get().resources) from(it.sourceSets.main.get().resources) } + + // this will ensure that this task is redone when the versions change. + inputs.properties(resourceProperties) + + filesMatching("META-INF/mods.toml") { + expand(resourceProperties) + } } tasks.jar { @@ -247,3 +258,7 @@ sourceSets.forEach { it.output.setResourcesDir(outputDir) it.java.destinationDirectory.set(outputDir) } + +tasks.withType { + notCompatibleWithConfigurationCache("uses Task.project at execution time") +} diff --git a/ForgeApi/build.gradle.kts b/ForgeApi/build.gradle.kts index ad51bb578..b5835d746 100644 --- a/ForgeApi/build.gradle.kts +++ b/ForgeApi/build.gradle.kts @@ -1,3 +1,5 @@ +import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact + plugins { id("java") id("idea") @@ -120,3 +122,7 @@ publishing { } } } + +tasks.withType { + notCompatibleWithConfigurationCache("uses Task.project at execution time") +} diff --git a/NeoForge/build.gradle.kts b/NeoForge/build.gradle.kts index 42ba7eec4..daa4df306 100644 --- a/NeoForge/build.gradle.kts +++ b/NeoForge/build.gradle.kts @@ -24,6 +24,8 @@ val modGroup: String by extra val modId: String by extra val modJavaVersion: String by extra +val resourceProperties: Map by rootProject.extra + // set by ORG_GRADLE_PROJECT_modrinthToken in Jenkinsfile val modrinthToken: String? by project @@ -61,10 +63,18 @@ tasks.withType().configureEach { } } -tasks.withType().configureEach { +tasks.withType { dependencyProjects.forEach { + 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 8f595a31d..2fb8cca1a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,6 +52,32 @@ val modJavaVersion: String by extra val modName: String by extra val specificationVersion: String by extra +//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" +} +val stringVersion = "${specificationVersion}.${buildNumber}" + +val resourceProperties by extra(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 stringVersion, +)) + spotless { java { target("*/src/*/java/mezz/jei/**/*.java") @@ -66,13 +92,7 @@ spotless { } subprojects { - //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}" + version = stringVersion group = modGroup tasks.withType { @@ -100,32 +120,6 @@ subprojects { } } - tasks.withType { - // this will ensure that this task is redone when the versions change. - inputs.property("version", version) - - filesMatching(listOf("META-INF/mods.toml", "META-INF/neoforge.mods.toml", "pack.mcmeta", "fabric.mod.json")) { - expand(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, - )) - } - } - // Activate reproducible builds // https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives tasks.withType().configureEach { diff --git a/gradle.properties b/gradle.properties index c0e86a0ec..bc6439d15 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,7 @@ org.gradle.daemon=true # Disabled because this breaks ForgeGradle tasks org.gradle.configureondemand=false org.gradle.caching=true +org.gradle.configuration-cache=true # JEI modName=Just Enough Items