refactor(android)!: restructure to standard Capacitor plugin layout
Restructure Android project from nested module layout to standard Capacitor plugin structure following community conventions. Structure Changes: - Move plugin code from android/plugin/ to android/src/main/java/ - Move test app from android/app/ to test-apps/android-test-app/app/ - Remove nested android/plugin module structure - Remove nested android/app test app structure Build Infrastructure: - Add Gradle wrapper files (gradlew, gradlew.bat, gradle/wrapper/) - Transform android/build.gradle from root project to library module - Update android/settings.gradle for standalone plugin builds - Add android/gradle.properties with AndroidX configuration - Add android/consumer-rules.pro for ProGuard rules Configuration Updates: - Add prepare script to package.json for automatic builds on npm install - Update package.json version to 1.0.1 - Update android/build.gradle to properly resolve Capacitor dependencies - Update test-apps/android-test-app/settings.gradle with correct paths - Remove android/variables.gradle (hardcode values in build.gradle) Documentation: - Update BUILDING.md with new structure and build process - Update INTEGRATION_GUIDE.md to reflect standard structure - Update README.md to remove path fix warnings - Add test-apps/BUILD_PROCESS.md documenting test app build flows Test App Configuration: - Fix android-test-app to correctly reference plugin and Capacitor - Remove capacitor-cordova-android-plugins dependency (not needed) - Update capacitor.settings.gradle path verification in fix script BREAKING CHANGE: Plugin now uses standard Capacitor Android structure. Consuming apps must update their capacitor.settings.gradle to reference android/ instead of android/plugin/. This is automatically handled by Capacitor CLI for apps using standard plugin installation.
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
*
|
||||
* Fixes:
|
||||
* 1. capacitor.plugins.json - Ensures DailyNotification plugin is registered
|
||||
* 2. capacitor.settings.gradle - Corrects plugin path from android/ to android/plugin/
|
||||
* 2. capacitor.settings.gradle - Verifies plugin path points to android/ (standard structure)
|
||||
*
|
||||
* This script should run automatically after 'npx cap sync android'
|
||||
* to fix issues with Capacitor's auto-generated files.
|
||||
* to verify Capacitor's auto-generated files are correct.
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
@@ -60,10 +60,10 @@ function fixCapacitorPlugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix capacitor.settings.gradle to point to android/plugin/ instead of android/
|
||||
* Fix capacitor.settings.gradle to verify plugin path points to android/ (standard structure)
|
||||
*/
|
||||
function fixCapacitorSettingsGradle() {
|
||||
console.log('🔧 Fixing capacitor.settings.gradle...');
|
||||
console.log('🔧 Verifying capacitor.settings.gradle...');
|
||||
|
||||
if (!fs.existsSync(SETTINGS_GRADLE_PATH)) {
|
||||
console.log('ℹ️ capacitor.settings.gradle not found (may not be a test-app)');
|
||||
@@ -74,30 +74,31 @@ function fixCapacitorSettingsGradle() {
|
||||
let content = fs.readFileSync(SETTINGS_GRADLE_PATH, 'utf8');
|
||||
const originalContent = content;
|
||||
|
||||
// Check if the path already points to android/plugin
|
||||
if (content.includes('android/plugin')) {
|
||||
console.log('✅ capacitor.settings.gradle already has correct path (android/plugin)');
|
||||
return;
|
||||
}
|
||||
// Check if the path correctly points to android/ (standard structure)
|
||||
const correctPath = "project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android')";
|
||||
const oldPluginPath = "project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android/plugin')";
|
||||
|
||||
// Check if we need to fix the path (points to android but should be android/plugin)
|
||||
if (content.includes("project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android')")) {
|
||||
// Replace the path
|
||||
// Check if it's using the old android/plugin/ path (needs fixing)
|
||||
if (content.includes('android/plugin')) {
|
||||
console.log('⚠️ capacitor.settings.gradle uses old path (android/plugin/) - fixing to standard structure');
|
||||
content = content.replace(
|
||||
"project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android')",
|
||||
`// NOTE: Plugin module is in android/plugin/ subdirectory, not android root
|
||||
// This file is auto-generated by Capacitor, but must be manually corrected for this plugin structure
|
||||
project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android/plugin')`
|
||||
oldPluginPath,
|
||||
`// Plugin uses standard Capacitor structure: android/ (not android/plugin/)
|
||||
${correctPath}`
|
||||
);
|
||||
|
||||
fs.writeFileSync(SETTINGS_GRADLE_PATH, content);
|
||||
console.log('✅ Fixed plugin path in capacitor.settings.gradle (android -> android/plugin)');
|
||||
if (content !== originalContent) {
|
||||
fs.writeFileSync(SETTINGS_GRADLE_PATH, content);
|
||||
console.log('✅ Fixed plugin path in capacitor.settings.gradle (android/plugin -> android)');
|
||||
}
|
||||
} else if (content.includes(correctPath) || content.includes("android')")) {
|
||||
console.log('✅ capacitor.settings.gradle has correct path (android/)');
|
||||
} else {
|
||||
console.log('ℹ️ capacitor.settings.gradle doesn\'t reference the plugin or uses a different structure');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error fixing capacitor.settings.gradle:', error.message);
|
||||
console.error('❌ Error verifying capacitor.settings.gradle:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user