feat: add protection against capacitor.build.gradle overwrites

- Create fix-capacitor-build.sh script to restore fixes after Capacitor operations
- Update build-native.sh to automatically apply fix when needed
- Add warnings to BUILDING.md about auto-generated file risks
- Document which Capacitor commands will overwrite manual fixes

This protects against losing the capacitor.build.gradle fix when running
npx cap sync, npx cap update, or other Capacitor CLI commands.
This commit is contained in:
Matthew Raymer
2025-10-12 06:15:52 +00:00
parent 300bd7f01f
commit a6d7d39c34
6 changed files with 49 additions and 5 deletions

View File

@@ -81,6 +81,15 @@ build_android() {
if [ ! -f "capacitor-cordova-android-plugins/cordova.variables.gradle" ]; then
log_warn "This appears to be a plugin development project"
log_warn "Android test app not properly initialized"
# Fix capacitor.build.gradle if needed
if [ -f "app/capacitor.build.gradle" ]; then
if grep -q "^apply from: \"../capacitor-cordova-android-plugins/cordova.variables.gradle\"" "app/capacitor.build.gradle"; then
log_info "Fixing capacitor.build.gradle for plugin development project..."
sed -i 's/^apply from: "\.\.\/capacitor-cordova-android-plugins\/cordova\.variables\.gradle"/\/\/ Plugin development project - no Capacitor integration files needed\n\/\/ &/' "app/capacitor.build.gradle"
fi
fi
log_warn "Plugin source code has been built successfully"
log_warn "To test the plugin, use it in a Capacitor app instead"
cd ..