forcedotcom / SalesforceMobileSDK-Templates

BSD 3-Clause "New" or "Revised" License
52 stars 56 forks source link

@W-14125965: [MSDK Android] Cannot Compile `MobileSyncExplorerKotlinTemplate` After MSDK Gradle 8 And Kotlin DSL Updates #369

Closed JohnsonEricAtSalesforce closed 1 year ago

JohnsonEricAtSalesforce commented 1 year ago

🎸 Ready For Review 🥁

This resolves an error when compiling the MSDK Android template apps, such as MobileSyncExplorerKotlinTemplate, where the publishing module Gradle Script Plugin introduced with the MSDK Gradle 8 and Kotlin DSL update cannot be accessed.

The error originates in how the template-based app includes MSDK in its Gradle workspace. The template-based app uses a separate Gradle include for specific MSDK modules. This doesn't include the overall MSDK workspace and leaves out anything in MSDK's build source.

As it turns out, simply migrating to a full composite build with MSDK greatly simplifies the configuration. MSDK builds with its full Gradle workspace, including the custom Gradle script plugin for the publishing module. This will likely make the Gradle integration between the app and MSDK much more robust in the future.

Also, since the app and MSDK are building together in Gradle from source, they will need to maintain the same Gradle and Android plugin versions. So, this gets those in sync as well.

There's more. Some React Native community libraries are not yet compatible with Android Gradle Plugin 8 and will not allow the workspace to sync. So, the Gradle scripts now include a check for the missing namespace property and apply a placeholder where needed, which is a work-around in the community. Note that the next version of React Native itself will migrate to Gradle 8 and Android Gradle Plugin 8, so the authors have posted a requirement that all community contributions will have to be compatible at that time.

I created a follow-up work item to migrate all these Gradle scripts to Kotlin DSL, since that would have made this set of changes difficult to follow in Github. See W-14149830

JohnsonEricAtSalesforce commented 1 year ago

It's worth noting I opened every template in Android Studio to verify Gradle sync and a run of the app on device will function correctly. It does take a little while!