Make Capacitor Cordova plugins optional in Android build#339
Make Capacitor Cordova plugins optional in Android build#3392witstudios wants to merge 1 commit intomasterfrom
Conversation
The Android build was failing when opened before running 'cap sync' because the capacitor-cordova-android-plugins directory (gitignored) didn't exist. Changes: - settings.gradle: Conditionally include cordova plugins project - build.gradle: Conditionally apply cordova dependencies and libs - Add fallback gradle config for builds before 'cap sync' is run https://claude.ai/code/session_016GBMtx46cJb7pGZeUDEAq9
📝 WalkthroughWalkthroughThe pull request introduces conditional handling of Cordova Android plugins across the build configuration. When the Cordova plugins directory exists, it's included normally; otherwise, a fallback configuration is applied to enable builds before capacitor sync operations complete. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR makes the
capacitor-cordova-android-pluginsmodule optional in the Android build configuration. The build system now gracefully handles scenarios where this module hasn't been generated yet (e.g., before runningcap sync), preventing build failures in fresh checkouts or CI environments.Key Changes
settings.gradleto only includecapacitor-cordova-android-pluginsif the directory existsapp/build.gradleto only add the cordova plugins project dependency when the module is presentcapacitor.build.gradle.fallbackfile that provides essential Capacitor plugin dependencies when cordova plugins aren't availablecapacitor.build.gradle(when cordova variables exist) or the fallback versionImplementation Details
File.exists()to determine if generated directories are presentpostBuildExtras()hook is preserved in the fallback for extensibilitypnpm syncThis approach enables the Android build to work in fresh clones and CI pipelines while maintaining full functionality once
cap synchas been executed.https://claude.ai/code/session_016GBMtx46cJb7pGZeUDEAq9
Summary by CodeRabbit