Browse Source
- Add detailed inline documentation in build-native.sh explaining the problem, why it happens, and the solution - Update fix-capacitor-build.sh with comprehensive header documentation - Include clear explanations of when the fix gets overwritten and how to restore it - Add user-friendly output with emojis and clear messaging - Document the automatic fix process with step-by-step explanations This provides complete transparency about what the scripts do and why, making it easy for developers to understand and maintain the fix.master
2 changed files with 104 additions and 9 deletions
@ -1,22 +1,75 @@ |
|||||
#!/bin/bash |
#!/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' |
# FIX SCRIPT: capacitor.build.gradle for Plugin Development Projects |
||||
|
# ============================================================================= |
||||
|
# |
||||
|
# PURPOSE: This script fixes a common issue in Capacitor plugin development |
||||
|
# projects where the auto-generated capacitor.build.gradle file tries to load |
||||
|
# a file that doesn't exist, causing build failures. |
||||
|
# |
||||
|
# WHEN TO USE: |
||||
|
# - After running 'npx cap sync' |
||||
|
# - After running 'npx cap update' |
||||
|
# - After running 'npx cap add android' |
||||
|
# - After any Capacitor CLI command that regenerates integration files |
||||
|
# - When you get build errors about missing cordova.variables.gradle |
||||
|
# |
||||
|
# WHAT IT DOES: |
||||
|
# - Finds the problematic line in capacitor.build.gradle |
||||
|
# - Comments it out with an explanatory comment |
||||
|
# - Prevents build failures in plugin development projects |
||||
|
# |
||||
|
# THE PROBLEM: |
||||
|
# Capacitor generates this line in capacitor.build.gradle: |
||||
|
# apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" |
||||
|
# But plugin development projects don't have this file, causing: |
||||
|
# "Could not read script '.../cordova.variables.gradle' as it does not exist" |
||||
|
# |
||||
|
# THE FIX: |
||||
|
# Comments out the problematic line and adds explanation: |
||||
|
# // Plugin development project - no Capacitor integration files needed |
||||
|
# // apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" |
||||
|
# |
||||
|
# ============================================================================= |
||||
|
|
||||
set -e |
set -e |
||||
|
|
||||
CAPACITOR_BUILD_GRADLE="android/app/capacitor.build.gradle" |
CAPACITOR_BUILD_GRADLE="android/app/capacitor.build.gradle" |
||||
|
|
||||
|
echo "🔧 DailyNotification Plugin - Capacitor Build Fix Script" |
||||
|
echo "========================================================" |
||||
|
|
||||
if [ -f "$CAPACITOR_BUILD_GRADLE" ]; then |
if [ -f "$CAPACITOR_BUILD_GRADLE" ]; then |
||||
echo "🔧 Fixing capacitor.build.gradle for plugin development project..." |
echo "📁 Found capacitor.build.gradle at: $CAPACITOR_BUILD_GRADLE" |
||||
|
|
||||
# Comment out the problematic line if it exists and isn't already commented |
# Check if the problematic line exists and isn't already commented |
||||
if grep -q "^apply from: \"../capacitor-cordova-android-plugins/cordova.variables.gradle\"" "$CAPACITOR_BUILD_GRADLE"; then |
if grep -q "^apply from: \"../capacitor-cordova-android-plugins/cordova.variables.gradle\"" "$CAPACITOR_BUILD_GRADLE"; then |
||||
|
echo "🔧 Applying fix to capacitor.build.gradle..." |
||||
|
echo " Problem: Line tries to load non-existent cordova.variables.gradle" |
||||
|
echo " Solution: Commenting out the problematic line" |
||||
|
|
||||
|
# Apply the fix by commenting out the problematic line |
||||
sed -i 's/^apply from: "\.\.\/capacitor-cordova-android-plugins\/cordova\.variables\.gradle"/\/\/ Plugin development project - no Capacitor integration files needed\n\/\/ &/' "$CAPACITOR_BUILD_GRADLE" |
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" |
|
||||
|
echo "✅ Fix applied successfully!" |
||||
|
echo "💡 The problematic line has been commented out with an explanation" |
||||
|
echo "⚠️ Note: This fix will be lost if you run Capacitor CLI commands again" |
||||
|
echo "🔄 To restore the fix later, run this script again or use the build script" |
||||
else |
else |
||||
echo "ℹ️ capacitor.build.gradle already fixed or doesn't need fixing" |
echo "ℹ️ capacitor.build.gradle already has the fix applied or doesn't need fixing" |
||||
|
echo " (The problematic line is either commented out or doesn't exist)" |
||||
fi |
fi |
||||
else |
else |
||||
echo "⚠️ capacitor.build.gradle not found at $CAPACITOR_BUILD_GRADLE" |
echo "⚠️ capacitor.build.gradle not found at: $CAPACITOR_BUILD_GRADLE" |
||||
|
echo " This may indicate:" |
||||
|
echo " - You're not in the correct directory" |
||||
|
echo " - The Android project structure is different" |
||||
|
echo " - The file hasn't been generated yet" |
||||
fi |
fi |
||||
|
|
||||
|
echo "" |
||||
|
echo "📚 For more information, see:" |
||||
|
echo " - BUILDING.md (troubleshooting section)" |
||||
|
echo " - scripts/build-native.sh (automatic fix documentation)" |
||||
|
echo "========================================================" |
||||
|
Loading…
Reference in new issue