Skip to content

feat: optimize brownfield-gradle-plugin#237

Open
hurali97 wants to merge 34 commits into
mainfrom
feat/revamp-plugin
Open

feat: optimize brownfield-gradle-plugin#237
hurali97 wants to merge 34 commits into
mainfrom
feat/revamp-plugin

Conversation

@hurali97
Copy link
Copy Markdown
Member

@hurali97 hurali97 commented Feb 22, 2026

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

benchmark

Copy link
Copy Markdown
Collaborator

@artus9033 artus9033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hurali97 hurali97 changed the title Feat/revamp plugin feat: optimize brownfield-gradle-plugin May 11, 2026
@hurali97 hurali97 marked this pull request as ready for review May 11, 2026 05:48
Copilot AI review requested due to automatic review settings May 11, 2026 05:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gradle-plugins/react/brownfield/build.gradle.kts Outdated
Comment thread apps/RNApp/android/gradle-profiler/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants