From 0fccbd53af86083a8742a33282dc183d07eb27a2 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 11 Jan 2022 07:22:22 -0800 Subject: [PATCH] Leverage Gradle implicit dependency substitution for Gradle Plugin Summary: Previously we asked users to specify a dependency substitution rule to properly use the React Native Gradle Plugin. Here I'm updating the Gradle Plugins setup to allow to use implicit dependency substitution. This requires to specify a Maven Group and Artifact Name (through the project name). This is backward compatible as users will still be allowed to specify a dependency substitution rule if they wish. Changelog: [Android] [Changed] - Leverage Gradle implicit dependency substitution for Gradle Plugin Reviewed By: ShikaSD Differential Revision: D33404948 fbshipit-source-id: 3323f8e0738fd579ce8ae344cbdc0e4356e7dbd8 --- packages/react-native-gradle-plugin/build.gradle.kts | 2 ++ packages/react-native-gradle-plugin/settings.gradle.kts | 2 ++ template/android/build.gradle | 2 +- template/android/settings.gradle | 6 +----- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts index 3c877cdbd4064a..fb9aa654c937fe 100644 --- a/packages/react-native-gradle-plugin/build.gradle.kts +++ b/packages/react-native-gradle-plugin/build.gradle.kts @@ -27,6 +27,8 @@ gradlePlugin { } } +group = "com.facebook.react" + dependencies { implementation(gradleApi()) implementation("com.android.tools.build:gradle:7.0.4") diff --git a/packages/react-native-gradle-plugin/settings.gradle.kts b/packages/react-native-gradle-plugin/settings.gradle.kts index db920b28b7dd4d..97f105d34f6eda 100644 --- a/packages/react-native-gradle-plugin/settings.gradle.kts +++ b/packages/react-native-gradle-plugin/settings.gradle.kts @@ -11,3 +11,5 @@ pluginManagement { google() } } + +rootProject.name = "react-native-gradle-plugin" diff --git a/template/android/build.gradle b/template/android/build.gradle index e99ff005bdbf61..8a1d68f9c5c74b 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -14,7 +14,7 @@ buildscript { } dependencies { classpath("com.android.tools.build:gradle:7.0.4") - classpath("com.facebook.react:react") + classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:4.1.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/template/android/settings.gradle b/template/android/settings.gradle index 9f74bf9d5f3857..2f93b7115036f3 100644 --- a/template/android/settings.gradle +++ b/template/android/settings.gradle @@ -1,11 +1,7 @@ rootProject.name = 'HelloWorld' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' -includeBuild('../node_modules/react-native-gradle-plugin') { - dependencySubstitution { - substitute(module("com.facebook.react:react")).using(project(":")) - } -} +includeBuild('../node_modules/react-native-gradle-plugin') if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { include(":ReactAndroid")