You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.5 KiB
75 lines
3.5 KiB
#!/bin/bash
|
|
|
|
# =============================================================================
|
|
# 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
|
|
|
|
CAPACITOR_BUILD_GRADLE="android/app/capacitor.build.gradle"
|
|
|
|
echo "🔧 DailyNotification Plugin - Capacitor Build Fix Script"
|
|
echo "========================================================"
|
|
|
|
if [ -f "$CAPACITOR_BUILD_GRADLE" ]; then
|
|
echo "📁 Found capacitor.build.gradle at: $CAPACITOR_BUILD_GRADLE"
|
|
|
|
# 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
|
|
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"
|
|
|
|
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
|
|
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
|
|
else
|
|
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
|
|
|
|
echo ""
|
|
echo "📚 For more information, see:"
|
|
echo " - BUILDING.md (troubleshooting section)"
|
|
echo " - scripts/build-native.sh (automatic fix documentation)"
|
|
echo "========================================================"
|
|
|