Skip to content

Conversation

@skydoves
Copy link
Member

Extracted duplicated Gradle build configuration from individual module build files into a centralized build-logic convention plugin system with reusable plugins, the build-logic configuration. I followed our KMP project (https://github.com/RevenueCat/purchases-kmp) for the overall structures.

Advantages of this build logic structure:

  1. Reduce duplication: Common configuration (Android settings, flavors, publishing, Metalava API tracking) is defined once and reused across all 7+ modules instead of being copy-pasted.
  2. Type-safety and IDE support: Kotlin DSL convention plugins provide compile-time validation, auto-completion, and refactoring capabilities that Groovy scripts don't have.
  3. Centralized maintenance: Changes to build configuration (like updating compile SDK or Kotlin options) only need to be made in one place rather than hunting through multiple build files.
  4. Enforces consistency: All library modules automatically get the same configuration through the convention plugins, preventing configuration drift between modules.

@skydoves skydoves self-assigned this Nov 11, 2025
@skydoves skydoves requested a review from a team as a code owner November 11, 2025 02:04
@skydoves skydoves added pr:dependencies Changes on external dependencies pr:other and removed pr:dependencies Changes on external dependencies labels Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.28%. Comparing base (cb540af) to head (b011871).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2827   +/-   ##
=======================================
  Coverage   78.28%   78.28%           
=======================================
  Files         330      330           
  Lines       12753    12753           
  Branches     1739     1739           
=======================================
  Hits         9984     9984           
  Misses       2038     2038           
  Partials      731      731           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Looking amzing! Thanks for doing this! 🙇 I think the only important question is whether we're still publishing the customEntitlementComputation in the purchases module.

}
create("customEntitlementComputation") {
dimension = "apis"
missingDimensionStrategy("apis", "defaults")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I know this was like this before but is this needed? I would think that in this case, there wouldn't be a missing dimension case, since the dimension is created right?

* Only applies publishing for variants that don't contain "customEntitlementComputation"
*/
internal fun Project.configureConditionalPublishing() {
if (!project.properties["ANDROID_VARIANT_TO_PUBLISH"].toString().contains("customEntitlementComputation")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I think this is applied to all public libraries, but we still want to be able to publish the CEC version of the purchases module right? We do want to skip it for the purchases-ui dependency + bom, so maybe we need to split this out somehow...

@skydoves
Copy link
Member Author

Awesome, @tonidero! I just applied your comments and resolved some issues on 57cdb12.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

So there were a bunch of conflicts with #2839 😢 sorry about that. Basically, I think it should just be applying the new flavor dimension billingclient (with bc8 and bc7 flavors) to the purchases, purchases-ui and purchase-store-amazon modules.

Otherwise, this PR looks good to me! Lmk if you need any help solving the conflicts, happy to help! 🙏

*/
internal fun Project.configureApisFlavors() {
extensions.configure<LibraryExtension> {
flavorDimensions += "apis"
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to add another one like this for the billingclient dimension, that may have bc8 (default) or bc7 flavors. This should be configured for the purchases, purchases-ui and puchases-store-amazon dependencies. No need for the debugview dependency. Sorry for the conflicts 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the detailed histories! 🙏 I just resolved the conflicts and configured the billingclient dimension on b011871.

Resolved conflicts by:
- Adding billingclient dimension (bc7/bc8) to purchases, purchases-ui, and purchases-store-amazon modules
- Removing duplicate 'apis' flavor dimension configuration (now handled by convention plugin)
- Keeping debugview without billingclient dimension as it doesn't need it
- Adding missingDimensionStrategy for billingclient to integration-tests
- Removing old .gradle files in favor of .kts versions

The billingclient dimension from PR #2839 is now integrated with the convention plugin structure from this PR.
The debugview module needs the billingclient dimension to match the ANDROID_VARIANT_TO_PUBLISH=defaultsBc8Release configuration in gradle.properties. Without this dimension, the maven publish plugin fails because it can't find the expected variant.

Even though debugview doesn't have flavor-specific source code like purchases module does, it needs the dimension for publishing compatibility.
@tonidero
Copy link
Contributor

Amazing work! Nice to clean this up! 🙌

@JayShortway
Copy link
Member

I am so excited about this! Thanks @skydoves 🙌

@skydoves skydoves added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit c37276b Nov 27, 2025
23 checks passed
@skydoves skydoves deleted the improve/gradles-kts branch November 27, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants