From 7383c00dd6cde4460b088daecda7923ed17a1a0f Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 20 Oct 2022 13:25:55 -0700 Subject: [PATCH] RNGP - Remove deprecated `useJavaGenerator` and `reactRoot` properties from extension Summary: This is part of a series of diffs to make the React Native Gradle Plugin (RNGP) variant-aware. Here I'm removing two deprecated properties `useJavaGenerator` and `reactRoot`. They were both not widely used, we had a deprecation warning and now they're just making the whole setup harder. Changelog: [Internal] [Changed] - RNGP - RNGP - Setup tasks to cleanup the Apk/Aab from unused .so Reviewed By: cipolleschi Differential Revision: D40547688 fbshipit-source-id: c4b8c1cef3a2abae1060e8ce2540e45d0313a4be --- .../com/facebook/react/ReactExtension.kt | 35 ------------------- .../kotlin/com/facebook/react/ReactPlugin.kt | 1 - .../tasks/GenerateCodegenArtifactsTask.kt | 30 ---------------- 3 files changed, 66 deletions(-) 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 848434a1b5836b..6c09759a0819c8 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 @@ -221,39 +221,4 @@ abstract class ReactExtension @Inject constructor(project: Project) { */ val codegenJavaPackageName: Property = objects.property(String::class.java).convention("com.facebook.fbreact.specs") - - /** - * Whether the Java Generator (based on Javapoet) should be used or not. Please note that this is - * currently deprecated as the Java generator is not supported anymore. Default: false - */ - @Deprecated( - level = DeprecationLevel.ERROR, - message = - "Please note that this is deprecated as the Java generator is not supported and react-native-codegen should be used instead.") - val useJavaGenerator: Property = objects.property(Boolean::class.java).convention(false) - - /** - * The `reactRoot` property was confusing and should not be used. - * - * You should instead use either: - * - [root] to point to your root project (where the package.json lives) - * - [reactNativeDir] to point to the NPM package of react native. - * - * A valid configuration would look like: - * - * ``` - * react { - * root = rootProject.file("..") - * reactNativeDir = rootProject.file("../node_modules/react-native") - * } - * ``` - * - * Please also note that those are the default value and you most likely don't need those at all. - */ - @Deprecated( - "reactRoot was confusing and has been replace with root " + - "to point to your root project and reactNativeDir to point to " + - "the folder of the react-native NPM package", - replaceWith = ReplaceWith("reactNativeRoot")) - val reactRoot: DirectoryProperty = objects.directoryProperty() } 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 f51a3dd8fa335c..034a6be090f8f2 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 @@ -117,7 +117,6 @@ class ReactPlugin : Plugin { "generateCodegenArtifactsFromSchema", GenerateCodegenArtifactsTask::class.java) { it.dependsOn(generateCodegenSchemaTask) it.reactNativeDir.set(extension.reactNativeDir) - @Suppress("DEPRECATION") it.deprecatedReactRoot.set(extension.reactRoot) it.nodeExecutableAndArgs.set(extension.nodeExecutableAndArgs) it.codegenDir.set(extension.codegenDir) it.generatedSrcDir.set(generatedSrcDir) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt index 59f9b343b0991b..12830982d0cabe 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt @@ -38,9 +38,6 @@ abstract class GenerateCodegenArtifactsTask : Exec() { @get:Input abstract val libraryName: Property - // We're keeping this just to fire a warning at the user should they use the `reactRoot` property. - @get:Internal abstract val deprecatedReactRoot: DirectoryProperty - @get:InputFile val combineJsToSchemaCli: Provider = codegenDir.file("lib/cli/combine/combine-js-to-schema-cli.js") @@ -53,38 +50,11 @@ abstract class GenerateCodegenArtifactsTask : Exec() { @get:OutputDirectory val generatedJniFiles: Provider = generatedSrcDir.dir("jni") override fun exec() { - checkForDeprecatedProperty() - val (resolvedLibraryName, resolvedCodegenJavaPackageName) = resolveTaskParameters() setupCommandLine(resolvedLibraryName, resolvedCodegenJavaPackageName) super.exec() } - private fun checkForDeprecatedProperty() { - if (deprecatedReactRoot.isPresent) { - project.logger.error( - """ - ******************************************************************************** - The `reactRoot` property is deprecated and will be removed in - future versions of React Native. The property is currently ignored. - - You should instead use either: - - [root] to point to your root project (where the package.json lives) - - [reactNativeDir] to point to the NPM package of react native. - - You should be fine by just removing the `reactRoot` line entirely from - your build.gradle file. Otherwise a valid configuration would look like: - - react { - root = rootProject.file('..') - reactNativeDir = rootProject.file('../node_modules/react-native') - } - ******************************************************************************** - """ - .trimIndent()) - } - } - internal fun resolveTaskParameters(): Pair { val parsedPackageJson = if (packageJsonFile.isPresent && packageJsonFile.get().asFile.exists()) {