De-bump AGP to 7.3.1 and do not use addGeneratedSourceDirectory (#35631)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35631

Fixes #35592
I'm de-bumping AGP from 7.4 to 7.3 as per #35592. There is no stable release
of AGP that is working fine with the `addGeneratedSourceDirectory` API for resources.
Here I'm reverting to use the older APIs.

Changelog:
[Internal] [Changed] - De-bump AGP to 7.3.1 and do not use `addGeneratedSourceDirectory`

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D42004813

fbshipit-source-id: f1a2b0f7c2233402749a3e4f3828be80111ad3a7
This commit is contained in:
Nicola Corti
2022-12-19 14:14:43 +00:00
committed by Riccardo Cipolleschi
parent e2e6ee363f
commit caa79b7c01
4 changed files with 17 additions and 3 deletions
@@ -33,7 +33,7 @@ group = "com.facebook.react"
dependencies {
implementation(gradleApi())
implementation("com.android.tools.build:gradle:7.4.0-beta05")
implementation("com.android.tools.build:gradle:7.3.1")
implementation("com.google.code.gson:gson:2.8.9")
implementation("com.google.guava:guava:31.0.1-jre")
implementation("com.squareup:javapoet:1.13.0")
@@ -8,6 +8,7 @@
package com.facebook.react
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.gradle.AppExtension
import com.android.build.gradle.internal.tasks.factory.dependsOn
import com.facebook.react.tasks.BuildCodegenCLITask
import com.facebook.react.tasks.GenerateCodegenArtifactsTask
@@ -54,6 +55,17 @@ class ReactPlugin : Plugin<Project> {
project.configureReactTasks(variant = variant, config = extension)
}
}
// This is a legacy AGP api. Needed as AGP 7.3 is not consuming generated resources correctly.
// Can be removed as we bump to AGP 7.4 stable.
// This registers the $buildDir/generated/res/react/<variant> folder as a
// res folder to be consumed with the old AGP Apis which are not broken.
project.extensions.getByType(AppExtension::class.java).apply {
this.applicationVariants.all {
it.registerGeneratedResFolders(
project.layout.buildDirectory.files("generated/res/react/${it.name}"))
}
}
configureCodegen(project, extension, isLibrary = false)
}
@@ -70,7 +70,9 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
it.hermesFlags.set(config.hermesFlags)
it.reactNativeDir.set(config.reactNativeDir)
}
variant.sources.res?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::resourcesDir)
// Currently broken inside AGP 7.3 We need to wait for a release of AGP 7.4 in order to use
// the addGeneratedSourceDirectory API.
// variant.sources.res?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::resourcesDir)
variant.sources.assets?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::jsBundleDir)
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.0-beta05")
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}