Skip to content

Commit f3f75e8

Browse files
cortinicohuntie
authored andcommitted
Fix projects being broken on dependencies starting with a.. (#41621)
Summary: Pull Request resolved: #41621 Currently, if you have a dependency that is alphabetically smaller than `app`, it's evaluation will happen before `app`. This means that the namespace auto-discovery and the JVM toolchain configuration won't be working and the project will fail to buid. This fixes it by introducing a root-project Gradle Plugin that takes care of enforcing the evaluation order on the `app` project. Fixes #41620 Changelog: [Android] [Fixed] - Fix projects being broken on dependencies starting with `a..` Reviewed By: huntie Differential Revision: D51547294 fbshipit-source-id: 65df7149548b7087dd8928e556fb803b3baf7b79
1 parent 830c2e7 commit f3f75e8

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

packages/react-native-gradle-plugin/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ gradlePlugin {
2626
id = "com.facebook.react"
2727
implementationClass = "com.facebook.react.ReactPlugin"
2828
}
29+
create("reactrootproject") {
30+
id = "com.facebook.react.rootproject"
31+
implementationClass = "com.facebook.react.ReactRootProjectPlugin"
32+
}
2933
}
3034
}
3135

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react
9+
10+
import org.gradle.api.Plugin
11+
import org.gradle.api.Project
12+
13+
/**
14+
* Gradle plugin applied to the `android/build.gradle` file.
15+
*
16+
* This plugin allows to specify project wide configurations that can be applied to both apps and
17+
* libraries before they're evaluated.
18+
*/
19+
class ReactRootProjectPlugin : Plugin<Project> {
20+
override fun apply(project: Project) {
21+
project.subprojects {
22+
// As the :app project (i.e. ReactPlugin) configures both namespaces and JVM toolchains
23+
// for libraries, its evaluation must happen before the libraries' evaluation.
24+
// Eventually the configuration of namespace/JVM toolchain can be moved inside this plugin.
25+
if (it.path != ":app") {
26+
it.evaluationDependsOn(":app")
27+
}
28+
}
29+
}
30+
}

packages/react-native/template/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
31
buildscript {
42
ext {
53
buildToolsVersion = "34.0.0"
@@ -19,3 +17,5 @@ buildscript {
1917
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
2018
}
2119
}
20+
21+
apply plugin: "com.facebook.react.rootproject"

0 commit comments

Comments
 (0)