diff --git a/scripts/build-native.sh b/scripts/build-native.sh index 33e3f9a..7c598b7 100755 --- a/scripts/build-native.sh +++ b/scripts/build-native.sh @@ -73,8 +73,72 @@ build_typescript() { fi } +build_plugin_for_test_app() { + log_info "Building plugin for test app..." + + # Build the plugin AAR + log_info "Building plugin AAR..." + cd android || exit 1 + if ! ./gradlew :plugin:clean :plugin:assembleDebug; then + log_error "Plugin build failed" + exit 1 + fi + + AAR_FILE="plugin/build/outputs/aar/plugin-debug.aar" + if [ ! -f "$AAR_FILE" ]; then + log_error "AAR file not found at $AAR_FILE" + exit 1 + fi + log_info "Plugin AAR built: $AAR_FILE" + + # Remove any stale AAR from test app's libs directory + if [ -f "../test-apps/daily-notification-test/android/app/libs/plugin-debug.aar" ]; then + log_info "Removing stale AAR from test app libs..." + rm "../test-apps/daily-notification-test/android/app/libs/plugin-debug.aar" + fi + + cd .. + + # Ensure symlink is in place + SYMLINK="test-apps/daily-notification-test/node_modules/@timesafari/daily-notification-plugin" + if [ ! -L "$SYMLINK" ] || [ ! -e "$SYMLINK" ]; then + log_info "Creating symlink to plugin..." + mkdir -p "$(dirname "$SYMLINK")" + rm -f "$SYMLINK" + ln -sf "../../../" "$SYMLINK" + fi + + # Build test app + log_info "Building test app..." + cd test-apps/daily-notification-test/android || exit 1 + + if ! ./gradlew clean assembleDebug; then + log_error "Test app build failed" + exit 1 + fi + + APK_FILE="app/build/outputs/apk/debug/app-debug.apk" + if [ ! -f "$APK_FILE" ]; then + log_error "APK file not found at $APK_FILE" + exit 1 + fi + + log_info "Test app build successful: $APK_FILE" + log_info "Install with: adb install -r $APK_FILE" + + cd ../../.. +} + build_android() { log_info "Building Android..." + + # Detect project type + if [ -d "test-apps/daily-notification-test" ]; then + log_info "Detected test app. Building plugin and test app together..." + build_plugin_for_test_app + return 0 + fi + cd android || exit 1 # Check if this is a plugin development project