Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/host/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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([
Expand Down Expand Up @@ -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()
}
}
Expand Down
Loading