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:
22
scripts/fix-capacitor-build.sh
Executable file
22
scripts/fix-capacitor-build.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fix for capacitor.build.gradle in plugin development projects
|
||||
# This script should be run after any 'npx cap sync' or 'npx cap update'
|
||||
|
||||
set -e
|
||||
|
||||
CAPACITOR_BUILD_GRADLE="android/app/capacitor.build.gradle"
|
||||
|
||||
if [ -f "$CAPACITOR_BUILD_GRADLE" ]; then
|
||||
echo "🔧 Fixing capacitor.build.gradle for plugin development project..."
|
||||
|
||||
# Comment out the problematic line if it exists and isn't already commented
|
||||
if grep -q "^apply from: \"../capacitor-cordova-android-plugins/cordova.variables.gradle\"" "$CAPACITOR_BUILD_GRADLE"; then
|
||||
sed -i 's/^apply from: "\.\.\/capacitor-cordova-android-plugins\/cordova\.variables\.gradle"/\/\/ Plugin development project - no Capacitor integration files needed\n\/\/ &/' "$CAPACITOR_BUILD_GRADLE"
|
||||
echo "✅ Fixed capacitor.build.gradle"
|
||||
else
|
||||
echo "ℹ️ capacitor.build.gradle already fixed or doesn't need fixing"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ capacitor.build.gradle not found at $CAPACITOR_BUILD_GRADLE"
|
||||
fi
|
||||
Reference in New Issue
Block a user