diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index 8538eaa9941d48..b6523cdf607c1b 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -96,7 +96,8 @@ class ReactPlugin : Plugin { // Please note that appNeedsCodegen is triggering a read of the package.json at // configuration time as we need to feed the onlyIf condition of this task. // Therefore, the appNeedsCodegen needs to be invoked inside this lambda. - it.onlyIf { isLibrary || project.needsCodegenFromPackageJson(extension) } + val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(extension) + it.onlyIf { isLibrary || needsCodegenFromPackageJson } } // We create the task to produce schema from JS files. @@ -120,7 +121,8 @@ class ReactPlugin : Plugin { } else { it.jsRootDir.set(extension.jsRootDir) } - it.onlyIf { isLibrary || project.needsCodegenFromPackageJson(parsedPackageJson) } + val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(extension) + it.onlyIf { isLibrary || needsCodegenFromPackageJson } } // We create the task to generate Java code from schema. @@ -139,7 +141,8 @@ class ReactPlugin : Plugin { // Please note that appNeedsCodegen is triggering a read of the package.json at // configuration time as we need to feed the onlyIf condition of this task. // Therefore, the appNeedsCodegen needs to be invoked inside this lambda. - it.onlyIf { isLibrary || project.needsCodegenFromPackageJson(extension) } + val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(extension) + it.onlyIf { isLibrary || needsCodegenFromPackageJson } } // We update the android configuration to include the generated sources.