diff --git a/packages/host/android/build.gradle b/packages/host/android/build.gradle index 39204133..396fd8f2 100644 --- a/packages/host/android/build.gradle +++ b/packages/host/android/build.gradle @@ -1,6 +1,8 @@ import java.nio.file.Paths import groovy.json.JsonSlurper +import javax.inject.Inject import org.gradle.internal.os.OperatingSystem +import org.gradle.process.ExecOperations if (!System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR")) { throw new GradleException([ @@ -161,17 +163,25 @@ dependencies { def commandLinePrefix = OperatingSystem.current().isWindows() ? ["cmd", "/c", "node"] : [] def cliPath = file("../bin/react-native-node-api.mjs") +// Gradle 9 removed Project.exec(), so the ExecOperations service has to be +// injected and used explicitly instead of the bare `exec {}` closure. +interface InjectedExecOps { + @Inject + ExecOperations getExecOps() +} +def injectedExecOps = project.objects.newInstance(InjectedExecOps) + // Custom task to fetch jniLibs paths via CLI task linkNodeApiModules { doLast { - exec { + injectedExecOps.execOps.exec { commandLine commandLinePrefix + [cliPath, 'link', '--android', rootProject.rootDir.absolutePath] standardOutput = System.out errorOutput = System.err // Enable color output environment "FORCE_COLOR", "1" } - + android.sourceSets.main.jniLibs.srcDirs += file("../auto-linked/android").listFiles() } }