mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RNGP - Remove unused applyAppPlugin
Summary: This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware. Here I'm removing the `applyAppPlugin` property which was never used. The new logic will apply the App Plugin if the `com.android.application` plugin is found. I've also removed the corresponding tests. New one will follow afterwards Changelog: [Internal] [Changed] - RNGP - Remove unused applyAppPlugin Reviewed By: cipolleschi Differential Revision: D40547689 fbshipit-source-id: ce1089498a586a43cb5e07950767c2c4b51b4597
This commit is contained in:
committed by
Facebook GitHub Bot
parent
affcfa7bde
commit
8e8e18be5e
-6
@@ -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<Boolean> = 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.
|
||||
|
||||
+9
-9
@@ -40,14 +40,14 @@ class ReactPlugin : Plugin<Project> {
|
||||
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<Project> {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
-56
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,6 @@ plugins {
|
||||
*/
|
||||
|
||||
react {
|
||||
applyAppPlugin = true
|
||||
cliPath = "../../../../cli.js"
|
||||
bundleAssetName = "RNTesterApp.android.bundle"
|
||||
entryFile = file("../../js/RNTesterApp.android.js")
|
||||
|
||||
Reference in New Issue
Block a user