feat: optimize brownfield-gradle-plugin#237
Open
hurali97 wants to merge 34 commits into
Open
Conversation
…nto feat/revamp-plugin
Contributor
There was a problem hiding this comment.
Pull request overview
This PR revamps the Android brownfield Gradle plugin to reduce configuration-phase work (notably avoiding forced artifact resolution), reworks how AARs are exploded/merged, and bumps the plugin version to 2.0.0-alpha01 (plus snapshot variants). It also adds Gradle Profiler scenarios/docs/scripts to benchmark build-time improvements.
Changes:
- Refactor brownfield Gradle plugin internals: replace prior variant processing/explode task wiring with new providers/tasks and an “unresolved artifact” model.
- Update plugin version references across the Expo config plugin, Gradle plugin, docs, and CI helper script.
- Add Gradle Profiler scenarios + helper scripts/docs for benchmarking.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-brownfield/src/expo-config-plugin/android/utils/constants.ts | Bump referenced brownfield Gradle plugin version. |
| gradle-plugins/react/README.md | Update installation docs to new plugin versions. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Utils.kt | Remove AGP version detection helper; keep file merge helper. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt | Remove dependency-resolution related extension flags; keep appProjectName/dylib options. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/DirectoryManager.kt | Switch variant parameterization from LibraryVariant to variantName string. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/AndroidArchiveLibrary.kt | Change artifact model + namespace detection strategy. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/ModuleInfo.kt | Add new artifact info model (UnresolvedArtifactInfo). |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/GradleProps.kt | Remove internal Gradle service plumbing class. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/ExplodeAarTask.kt | Add new task to explode AARs + run class merge steps. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/BundleTaskProvider.kt | Add helper to find appropriate bundle task across variant dimensions. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantTaskProvider.kt | Replace old variant task wiring with new preBuild/dataBinding handling. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantProcessor.kt | Remove prior end-to-end variant processor implementation. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantPackagesProperty.kt | Change stored property from AndroidArchiveLibrary list to String package list. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt | Refactor merge helpers to accept variantName and minify flag. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ResourceTaskProcessor.kt | Add processor to register generated resource folders. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ProguardProcessor.kt | Refactor proguard merging to accept explicit rule file list. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/MergeProcessor.kt | Remove jar-to-libs merge helper. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ManifestTaskProcessor.kt | Add new manifest merge processor based on ManifestMerger2. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt | Refactor JNI libs processing to take variantName string. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ExplodeTaskProvider.kt | Add provider to register/configure the new explode task. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/AssetTaskProcessor.kt | Add processor to wire exploded AAR assets into source sets. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt | Update source set wiring to use the new Variant API (androidComponents.onVariants). |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNBrownfieldPlugin.kt | Rewrite plugin apply flow to new configuration + task wiring approach. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RClassTransformer.kt | Update transformer params to consume package-name strings directly. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/ProjectConfigurations.kt | Rework configuration setup and attribute copying strategy. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/ManifestMerger.kt | Remove old custom manifest merger task implementation. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/CustomDependencyResolver.kt | Minor refactor (string slicing) in compileOnly mirroring logic. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/expo/utils/LocalMavenUtils.kt | Add helper utilities for Expo local-maven file/publishing info. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/expo/ExpoPublishingHelper.kt | Refactor to return projections and reuse LocalMavenUtils. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/FlavorArtifact.kt | Remove old flavor artifact resolution implementation. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/artifacts/ArtifactsResolver.kt | Replace resolved-artifact approach with “unresolved artifact info” list building. |
| gradle-plugins/react/brownfield/gradle.properties | Bump plugin VERSION to 2.0.0-alpha01. |
| gradle-plugins/react/brownfield/build.gradle.kts | Add Kotlin serialization plugin; adjust publishing metadata. |
| apps/scripts/prepare-android-build-gradle-for-ci.ts | Bump snapshot plugin version used in CI script. |
| apps/RNApp/android/gradle-profiler/scenarios.txt | Add Gradle Profiler scenario definition. |
| apps/RNApp/android/gradle-profiler/README.md | Add instructions for running Gradle Profiler benchmarks. |
| apps/RNApp/android/gradle-profiler/print.sh | Add script to compare benchmark outputs. |
| apps/RNApp/android/gradle-profiler/benchmarks/old.txt | Add baseline benchmark sample. |
| apps/RNApp/android/gradle-profiler/benchmarks/new.txt | Add “optimized” benchmark sample. |
| apps/RNApp/android/build.gradle | Bump snapshot plugin version used by sample app. |
| apps/RNApp/.gitignore | Ignore Gradle profiler output directories. |
| .changeset/red-plants-roll.md | Changeset for bumping @callstack/react-native-brownfield. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR revamps the brownfield Gradle plugin to avoid configuration-time artifact resolution and to reduce tight coupling between “explode”, “merge”, and other variant tasks. The implementation shifts to a task-driven, variant-aware pipeline: we first collect lightweight dependency metadata (UnresolvedArtifactInfo), then for each LibraryVariant we wire dedicated processors/tasks (explode AARs, merge manifests/resources/assets, JNI libs, proguard rules, databinding) instead of using a monolithic VariantProcessor.
We also modernize parts of the plugin to better align with newer AGP patterns (variant APIs / attributes), simplify Expo publishing integration via LocalMavenUtils, and remove legacy/deprecated plumbing (e.g., custom ManifestMerger, FlavorArtifact, GradleProps, and unused extension flags).
Test plan