Skip to content

Commit

Permalink
Make sure buildConfig is turned on for all the 3rd party libraries (f…
Browse files Browse the repository at this point in the history
…acebook#40939)

Summary:
Pull Request resolved: facebook#40939

Currently some libs on RN 0.73 are broken as the default for Build Config generation changed
from true to false since AGP 8.x. This reverts the behavior to the old flag.

Closes facebook#40791
Closes facebook#40559

Changelog:
[Internal] [Changed] - Make sure buildConfig is turned on for all the 3rd party libraries

Reviewed By: mdvacca

Differential Revision: D50270382

fbshipit-source-id: 02dcb031c577f65be2f41d9da0334c1b3d89e4c5
  • Loading branch information
cortinico authored and yayvery committed Jan 14, 2024
1 parent 6f34aca commit 549cff4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn
import com.facebook.react.internal.PrivateReactExtension
import com.facebook.react.tasks.GenerateCodegenArtifactsTask
import com.facebook.react.tasks.GenerateCodegenSchemaTask
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFields
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForApp
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForLibraries
import com.facebook.react.utils.AgpConfiguratorUtils.configureDevPorts
import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap
import com.facebook.react.utils.DependencyUtils.configureDependencies
Expand Down Expand Up @@ -64,7 +65,7 @@ class ReactPlugin : Plugin<Project> {
}

configureReactNativeNdk(project, extension)
configureBuildConfigFields(project)
configureBuildConfigFieldsForApp(project)
configureDevPorts(project)
configureBackwardCompatibilityReactMap(project)

Expand All @@ -83,6 +84,7 @@ class ReactPlugin : Plugin<Project> {

// Library and App Configurations
configureJavaToolChains(project)
configureBuildConfigFieldsForLibraries(project)
}

private fun checkJvmVersion(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.gradle.api.plugins.AppliedPlugin
@Suppress("UnstableApiUsage")
internal object AgpConfiguratorUtils {

fun configureBuildConfigFields(project: Project) {
fun configureBuildConfigFieldsForApp(project: Project) {
val action =
Action<AppliedPlugin> {
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
Expand All @@ -32,6 +32,16 @@ internal object AgpConfiguratorUtils {
project.pluginManager.withPlugin("com.android.library", action)
}

fun configureBuildConfigFieldsForLibraries(appProject: Project) {
appProject.rootProject.allprojects { subproject ->
subproject.pluginManager.withPlugin("com.android.library") {
subproject.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
ext.buildFeatures.buildConfig = true
}
}
}
}

fun configureDevPorts(project: Project) {
val devServerPort =
project.properties["reactNativeDevServerPort"]?.toString() ?: DEFAULT_DEV_SERVER_PORT
Expand Down

0 comments on commit 549cff4

Please sign in to comment.