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#40791)

Summary:
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

Differential Revision: D50270382
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 13, 2023
1 parent f00594b commit 28f6840
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 @@ -66,7 +67,7 @@ class ReactPlugin : Plugin<Project> {
}

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

Expand All @@ -85,6 +86,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 @@ -18,7 +18,7 @@ import org.gradle.api.plugins.AppliedPlugin
@Suppress("UnstableApiUsage")
internal object AgpConfiguratorUtils {

fun configureBuildConfigFields(project: Project, extension: ReactExtension) {
fun configureBuildConfigFieldsForApp(project: Project, extension: ReactExtension) {
val action =
Action<AppliedPlugin> {
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
Expand All @@ -35,6 +35,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 28f6840

Please sign in to comment.