Skip to content

refactor: remove deprecated apis from brownfield-gradle-plugin#367

Merged
hurali97 merged 62 commits into
mainfrom
refactor/bgp/remove-deprecated-apis
Jul 9, 2026
Merged

refactor: remove deprecated apis from brownfield-gradle-plugin#367
hurali97 merged 62 commits into
mainfrom
refactor/bgp/remove-deprecated-apis

Conversation

@hurali97

@hurali97 hurali97 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

This replaces the deprecated APIs like LibraryVariant, legacy DSL and others to instead use the latest ones. This is required to ensure a smooth adoption once AGP v9 lands.

Also tested this PR locally with RNApp enabling AGP v9 and it works well 🚀

Test plan

  • CI passes
  • Verified Locally

@hurali97 hurali97 changed the title Refactor/bgp/remove deprecated apis refactor: remove deprecated apis from brownfield-gradle-plugin Jul 3, 2026
Comment on lines +113 to +119
//tasks.named("detekt").configure {
// dependsOn(":ktlintFormat")
//}
//
//tasks.register("lint") {
// dependsOn(":ktlintFormat")
//}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you sure this is to remain?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah no 😄 Self review of this PR is pending, will do it Monday!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alright :D

@hurali97 hurali97 marked this pull request as ready for review July 8, 2026 08:58
Copilot AI review requested due to automatic review settings July 8, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@artus9033 artus9033 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM after few comments resolved!

Comment on lines +20 to +24
androidComponent?.buildTypes?.forEach {
if (it.name == variant.name || it.name == variant.buildType) {
if (androidComponent.productFlavors.isEmpty()) {
taskName = it.name.capitalized()
return@forEach

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The old implementation matched dependency variants using missingDimensionStrategies fallbacks. With product flavors, the code now always picks the first flavor, not the flavor for the current variant. Are we sure this is the best way to go?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The reason of removing the old implementation is that it was never used.

The legacy implementation was there to handle the cases where a third party library could define different flavors, dimensions and missingDimensionsStrategy. However, most react native libraries do not define extra flavors and dims other than the stock release and debug ones. The missingDimensionsStrategy would still need to be defined on the third party library level and I am not aware of any library followed this.

In a way, most public packages do not define the flavors on their libraries as it is then a responsibility of the consumer :app to define the missing dimension. This is a classic way even without brownfield.

However, since we know some people like to do things differently, we still support missing dimensions but they have to be defined on the :brownfield module like:

missingDimensionStrategy(dimToUse, flavorToUse)

Verified this flow by adding flavor and dimension to brownfield-navigation and it works as expected.

However, I would like to address your next point below, which changes things a bit!

With product flavors, the code now always picks the first flavor, not the flavor for the current variant.

Thanks for pointing this out. However a subtle correction, the code always picks the last flavor, regardless this is an incorrect behavior as we do not know which flavor to pick.

With the new LibraryExtension API, we do not have a way to know what missingDimensionStrategy the consumer project defined. To allow BGP to know what missing strategy to use, we expose an extension property:

reactBrownfield {
    missingDimensionStrategies = listOf(dimToUse, flavorToUse)
}

Then we read it during our logic and pick the matching one. If no match is found, we throw an error!

See the updated code, thanks!


return matchedVariant?.let { variantTaskProvider.bundleTaskProvider(project, it.name) }
}
return variantTaskProvider.bundleTaskProvider(project, taskName)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we sure this will be non-null at all times? Don't we want to use optional chaining + optional task as we used to?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, because the previous approach used .find which can be null, so we had to use optionality check, now we always have a task name.

@artus9033 artus9033 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM after 1 nit comment!

@hurali97 hurali97 merged commit dd1082a into main Jul 9, 2026
22 of 25 checks passed
@hurali97 hurali97 deleted the refactor/bgp/remove-deprecated-apis branch July 9, 2026 12:08
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