diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index 44f0e6b9933f81..848434a1b5836b 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -22,12 +22,6 @@ abstract class ReactExtension @Inject constructor(project: Project) { private val objects = project.objects - /** - * Whether the React App plugin should apply its logic or not. Set it to false if you're still - * relying on `react.gradle` to configure your build. Default: false - */ - val applyAppPlugin: Property = objects.property(Boolean::class.java).convention(false) - /** * The path to the root of your project. This is the path to where the `package.json` lives. All * the CLI commands will be invoked from this folder as working directory. 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 81a708ff0456e5..f51a3dd8fa335c 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 @@ -40,14 +40,14 @@ class ReactPlugin : Plugin { if ((jvmVersion?.toIntOrNull() ?: 0) <= 8) { project.logger.error( """ - + ******************************************************************************** - + ERROR: requires JDK11 or higher. Incompatible major version detected: '$jvmVersion' - + ******************************************************************************** - + """ .trimIndent()) exitProcess(1) @@ -55,11 +55,11 @@ class ReactPlugin : Plugin { } private fun applyAppPlugin(project: Project, config: ReactExtension) { - configureReactNativeNdk(project, config) - configureBuildConfigFields(project) - configureDevPorts(project) - project.afterEvaluate { - if (config.applyAppPlugin.getOrElse(false)) { + project.pluginManager.withPlugin("com.android.application") { + configureReactNativeNdk(project, config) + configureBuildConfigFields(project) + configureDevPorts(project) + project.afterEvaluate { val isAndroidLibrary = project.plugins.hasPlugin("com.android.library") val variants = if (isAndroidLibrary) { diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt deleted file mode 100644 index 39caba83bfaf92..00000000000000 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react - -import com.android.build.gradle.AppExtension -import org.gradle.testfixtures.ProjectBuilder -import org.junit.Assert.assertTrue -import org.junit.Test - -class ReactPluginTest { - - @Test - fun reactPlugin_withApplyAppPluginSetToTrue_addsARelevantTask() { - val project = ProjectBuilder.builder().build() - project.plugins.apply("com.android.application") - project.plugins.apply("com.facebook.react") - - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } - project.extensions.getByType(ReactExtension::class.java).apply { - applyAppPlugin.set(true) - cliPath.set(".") - } - - // We check if the App Plugin si applied by finding one of the added task. - assertTrue(project.getTasksByName("bundleDebugJsAndAssets", false).isNotEmpty()) - } - - @Test - fun reactPlugin_withApplyAppPluginSetToFalse_doesNotApplyTheAppPlugin() { - val project = ProjectBuilder.builder().build() - project.plugins.apply("com.android.application") - project.plugins.apply("com.facebook.react") - - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } - project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } - - assertTrue(project.getTasksByName("bundleDebugJsAndAssets", false).isEmpty()) - } - - @Test - fun reactPlugin_withApplyAppPluginSetToFalse_codegenPluginIsApplied() { - val project = ProjectBuilder.builder().build() - project.plugins.apply("com.android.application") - project.plugins.apply("com.facebook.react") - - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } - project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } - - assertTrue(project.getTasksByName("buildCodegenCLI", false).isNotEmpty()) - } -} diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 2fe27d3fa0cc5b..e80589e004d32b 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -76,7 +76,6 @@ plugins { */ react { - applyAppPlugin = true cliPath = "../../../../cli.js" bundleAssetName = "RNTesterApp.android.bundle" entryFile = file("../../js/RNTesterApp.android.js")