Files
life-echo/app-android/Makefile

72 lines
2.0 KiB
Makefile
Raw Normal View History

# Life Echo Android 构建脚本
# 使用方法make release VERSION=1.2.3 CODE=10
# 默认版本号
VERSION ?= 1.0.0
CODE ?= 1
.PHONY: help release debug clean install
help:
@echo "Life Echo Android 构建命令:"
@echo ""
@echo " make release VERSION=1.2.3 CODE=10 - 构建 Release APK指定版本号"
@echo " make debug - 构建 Debug APK"
@echo " make clean - 清理构建文件"
@echo " make install - 安装到连接的设备"
@echo ""
@echo "参数:"
@echo " VERSION - 版本名称,如 1.2.3(默认: $(VERSION)"
@echo " CODE - 版本代码(整数),如 10默认: $(CODE)"
@echo ""
@echo "示例:"
@echo " make release VERSION=2.0.0 CODE=20"
# 构建 Release 版本
release:
@echo "🚀 构建 Release 版本..."
@echo " 版本名称: $(VERSION)"
@echo " 版本代码: $(CODE)"
JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home" ./gradlew assembleRelease \
-PversionName=$(VERSION) \
-PversionCode=$(CODE)
@echo "✅ 构建完成!"
@echo "📦 APK 位置: app/build/outputs/apk/release/岁月留书_v$(VERSION)_release.apk"
# 构建 Debug 版本
debug:
@echo "🔧 构建 Debug 版本..."
./gradlew assembleDebug
@echo "✅ Debug 版本构建完成!"
# 构建 Debug Prod 版本(生产环境调试)
debug-prod:
@echo "🔧 构建 Debug Prod 版本..."
./gradlew assembleDebugProd \
-PversionName=$(VERSION) \
-PversionCode=$(CODE)
@echo "✅ Debug Prod 版本构建完成!"
# 清理构建
clean:
@echo "🧹 清理构建文件..."
./gradlew clean
@echo "✅ 清理完成!"
# 安装到设备
install: release
@echo "📱 安装到设备..."
./gradlew installRelease
@echo "✅ 安装完成!"
# 列出所有构建变体
variants:
@echo "📋 可用的构建变体:"
./gradlew tasks --group=build
# 显示当前版本信息
version:
@echo "当前版本配置:"
@echo " VERSION = $(VERSION)"
@echo " CODE = $(CODE)"