From a86a54e7edaa9a57eefaa182996528d1dc2066e1 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Wed, 17 May 2023 11:11:30 -0700 Subject: [PATCH] fix: [gradle-plugin] 3rd party lib dependency substitution (#37445) Summary: For 3rd party libraries to work with a React Native fork (such as the TV repo) that uses a different Maven group for `react-android` and `hermes-android` artifacts, an additional dependency substitution is required. ## Changelog: [Android][fixed] RNGP dependency substitutions for fork with different Maven group Pull Request resolved: https://github.com/facebook/react-native/pull/37445 Test Plan: - Manual tested with an existing project - Unit tests pass Reviewed By: rshest, dmytrorykun Differential Revision: D45948901 Pulled By: cortinico fbshipit-source-id: 4151a1d3616172a92c68812c3a0034c98b330d67 --- .../kotlin/com/facebook/react/utils/DependencyUtils.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index 583fc13f377dd5..ecf083007aace5 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -69,6 +69,16 @@ internal object DependencyUtils { .using(it.module("${groupString}:hermes-android:${versionString}")) .because( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.") + if (groupString != DEFAULT_GROUP_STRING) { + it.substitute(it.module("com.facebook.react:react-android")) + .using(it.module("${groupString}:react-android:${versionString}")) + .because( + "The react-android dependency was modified to use the correct Maven group.") + it.substitute(it.module("com.facebook.react:hermes-android")) + .using(it.module("${groupString}:hermes-android:${versionString}")) + .because( + "The hermes-android dependency was modified to use the correct Maven group.") + } } configuration.resolutionStrategy.force( "${groupString}:react-android:${versionString}",