From 2d714f034f3babc52e73f7f13adfb0e42db74b26 Mon Sep 17 00:00:00 2001 From: sciwhiz12 Date: Sun, 18 Dec 2022 01:50:26 +0800 Subject: [PATCH] [1.19.2] Fix compatibility checker task configuration (#9233) * Fix compatibility checker task configuration The setupCheckJarCompatibility task exists to configure the main compatibility checker task, checkJarCompatibility, because certain configuration steps for that task could not be done until after the configuration phase of Gradle. However, that setup task previously held all the configuration for the main check task in its task action. This caused problems because the main check task's inputs are linked to other tasks, and the previous situation made it so its configuration (by the setup task) happened _after_ Gradle built the task dependency model/tree. This meant that certain tasks which the main check task depended on did not run before that task, because Gradle was unaware of this inter-task dependency until it was too late (when it was already executing tasks). This fixes the issue by moving the bulk of the configuration for the main check task from the action of the setup task to the main buildscript, therefore allowing Gradle to know about those task dependencies and factor them in to its process of determining what tasks to run and in what order. The remaining configuration step in the setup task for the main check task is linked to the setup task, and does not affect the task's dependencies (because it uses a configuration which it resolves immediately), so it stays in the setup task. * Force checker setup task to never be up-to-date The setup task configures the main check task, so it should always run before that task. However, because it has an input and output, the setup task is affected by Gradle's incremental build feature, which leads to the possibility that Gradle considers the setup task as up-to-date, therefore not executing its action and causing errors with the main check task down the line. --- build.gradle | 8 ++++++++ .../forge/tasks/SetupCheckJarCompatibility.groovy | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 1546061424..04b8619165 100644 --- a/build.gradle +++ b/build.gradle @@ -1241,6 +1241,14 @@ project(':forge') { dependsOn 'setupCheckJarCompatibility' baseJar = project.tasks.named('mergeBaseForgeJar').flatMap { it.output } + baseLibraries.from(project.tasks.named('createJoinedSRG').flatMap { it.output }) + + inputJar = project.tasks.named('reobfJar').flatMap { it.output } + concreteLibraries.from(project.PACKED_DEPS.collect { project.rootProject.tasks.getByPath(it).archiveFile }) + + commonLibraries.from(project.configurations.minecraftImplementation) + commonLibraries.from(project.configurations.installer) + commonLibraries.from(project.configurations.moduleonly) } task checkAll(dependsOn: [checkATs, checkSAS, checkExcs, findFieldInstanceChecks, checkPatches, checkLicenses]){} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/SetupCheckJarCompatibility.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/SetupCheckJarCompatibility.groovy index 045a70405f..d7f76b672e 100644 --- a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/SetupCheckJarCompatibility.groovy +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/SetupCheckJarCompatibility.groovy @@ -18,6 +18,7 @@ abstract class SetupCheckJarCompatibility extends DefaultTask { onlyIf { inputVersion.getOrNull() != null } + outputs.upToDateWhen { false } // Never up to date, because this setup task should always run baseBinPatchesOutput.convention(project.layout.buildDirectory.dir(name).map { it.file('joined.lzma') }) } @@ -31,17 +32,9 @@ abstract class SetupCheckJarCompatibility extends DefaultTask { }.toArray(Dependency[]::new)) project.tasks.named('checkJarCompatibility') { - baseLibraries.from(project.tasks.createJoinedSRG.output) baseLibraries.from(project.provider { fmlLibs.resolvedConfiguration.lenientConfiguration.files }) - - inputJar = project.tasks.reobfJar.output - concreteLibraries.from(project.PACKED_DEPS.collect { project.rootProject.tasks.getByPath(it).archiveFile }) - - commonLibraries.from(project.configurations.minecraftImplementation) - commonLibraries.from(project.configurations.installer) - commonLibraries.from(project.configurations.moduleonly) } def baseForgeUserdev = project.layout.buildDirectory.dir(name).map { it.file("forge-${inputVersion}-userdev.jar") }.get().asFile