Gradle Configuration Cache - Round 3 (#49439)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49439

This is the next part of a series of diff needed to enable G. Configuration Cache:
https://docs.gradle.org/current/userguide/configuration_cache.html
as it will make our CI faster (and will be the default in the future Gradle version).

Here I'm removing the `onlyIf` lambdas to make some tasks CC friendly.

The problem is that some `onlyIf` lambdas can't easily be serialized. Here I'm cleaning up
the problematic one to move the condition checks at execution time

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D69664732

fbshipit-source-id: a457b2fae8114568ec4e04d772c9944022b1e1a5
This commit is contained in:
Nicola Corti
2025-02-17 03:35:43 -08:00
committed by Facebook GitHub Bot
parent 0014265795
commit 43cffb96db
3 changed files with 9 additions and 6 deletions
@@ -28,6 +28,8 @@ abstract class BuildCodegenCLITask : Exec() {
@get:Internal abstract val bashWindowsHome: Property<String>
@get:Internal abstract val rootProjectName: Property<String>
@get:InputFiles abstract val inputFiles: Property<FileTree>
@get:OutputFiles abstract val outputFiles: Property<FileTree>
@@ -35,6 +37,10 @@ abstract class BuildCodegenCLITask : Exec() {
@get:OutputFile abstract val logFile: RegularFileProperty
override fun exec() {
// For build from source scenario, we don't need to build the codegen at all.
if (rootProjectName.get() == "react-native-build-from-source") {
return
}
val logFileConcrete =
logFile.get().asFile.apply {
parentFile.mkdirs()
@@ -426,10 +426,7 @@ val buildCodegenCLI by
include("lib/**/*.js")
include("lib/**/*.js.flow")
})
onlyIf {
// For build from source scenario, we don't need to build the codegen at all.
rootProject.name != "react-native-build-from-source"
}
rootProjectName.set(rootProject.name)
}
/**
@@ -124,8 +124,8 @@ val unzipHermes by
// the two tasks mentioned before, so we install CMake manually to break the circular dependency.
val installCMake by
tasks.registering(Exec::class) {
onlyIf { !File(cmakePath).exists() }
tasks.registering(CustomExecTask::class) {
onlyIfProvidedPathDoesNotExists.set(cmakePath)
commandLine(
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}"))
}