diff --git a/.winboll/bashMergeProjects-to-Projects_Keeper.sh b/.winboll/bashMergeProjects-to-Projects_Keeper.sh index 4107843..e633313 100644 --- a/.winboll/bashMergeProjects-to-Projects_Keeper.sh +++ b/.winboll/bashMergeProjects-to-Projects_Keeper.sh @@ -1,5 +1,5 @@ #!/system/bin/sh -## 合并其他项目分支的模块源码到projects_keeper分支。 +## 合并其他项目分支的模块源码到projects-keeper分支。 # ====================== 0. 进入目标目录 ====================== TARGET_DIR="/sdcard/AppProjects/Projects_Keeper" @@ -36,7 +36,7 @@ fi # ====================== 3. Git 分支检查 ====================== CUR_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null) -TARGET_BRANCH="projects_keeper" +TARGET_BRANCH="projects-keeper" if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then echo "错误:当前不在 $TARGET_BRANCH 分支!" @@ -72,7 +72,6 @@ libaes libappbase libdebugtemp libgpsrelaysentinel -libwinboll local.properties-demo mymessagemanager positions @@ -158,7 +157,7 @@ echo -e "## 对象列表结束 ## 合并 APP 项目 MERGE_APP_PROJECT_LIST=( -DemoAPP +WinBoLL ) echo -e "#@@@ 开始合并应用型模块源码 @@@# ## 目标合并对象列表:" @@ -173,7 +172,6 @@ done ## 合并 LIB 项目 MERGE_LIB_PROJECT_LIST=( -WinBoLL APPBase AES ) @@ -189,4 +187,4 @@ git checkout origin/$item_lower $item_lower lib$item_lower done echo '正在推送 Projects_Keeper 项目' -git push \ No newline at end of file +git push diff --git a/.winboll/bashMergeProjects-to-Projects_Keeper_Tag.sh b/.winboll/bashMergeProjects-to-Projects_Keeper_Tag.sh new file mode 100644 index 0000000..520335a --- /dev/null +++ b/.winboll/bashMergeProjects-to-Projects_Keeper_Tag.sh @@ -0,0 +1,144 @@ +#!/system/bin/sh +## 逻辑:按时间取最新标签 → 拉取该标签目录合并 + +# 按创建时间取模块最新标签(最新打的标签排最后) +get_latest_module_tag(){ + local mod=$1 + git for-each-ref --sort=-creatordate --format='%(refname)' refs/tags/${mod}-* \ + | grep -v '\^{}' \ + | head -1 \ + | sed 's/refs\/tags\///' +} + +# 通过标签获取commit +get_commit_from_tag(){ + local tag=$1 + git rev-parse --short "${tag}^{commit}" +} + +# 工作目录 +TARGET_DIR="/sdcard/AppProjects/Projects_Keeper_Tag" +echo "进入目录:${TARGET_DIR}" +cd "${TARGET_DIR}" || exit 1 + +# 同步远程 +echo "========================================" +echo "同步远程分支与全部版本标签" +echo "========================================" +git fetch origin --prune +git fetch origin --tags +echo "同步完成" +echo "" + +# 校验目标分支 +NOW_BRANCH=$(git symbolic-ref --short HEAD) +TARGET_BRANCH="projects_keeper_tag" +if [ "${NOW_BRANCH}" != "${TARGET_BRANCH}" ];then + echo "错误:请先切换到 ${TARGET_BRANCH} 分支" + exit 1 +fi + +# 目录结构校验 +MERGE_OBJECTS_LIST=( +.git +.gitignore +.gitmodules +.winboll +GenKeyStore +LICENSE +LICENSE-Private-Demo +LICENSE-Private-Demo_docs +README.md +aes +appbase +autonfc +build.gradle +contacts +debugtemp +gallery +gpsrelaysentinel +gradle +gradle.properties-android-demo +gradle.properties-androidx-demo +gradlew +libaes +libappbase +libdebugtemp +libgpsrelaysentinel +local.properties-demo +mymessagemanager +positions +powerbell +settings.gradle-demo +winboll +winboll.properties-demo +) + +REAL_ITEMS=() +while IFS= read -r line; do + [[ $line != "." && $line != ".." ]] && REAL_ITEMS+=("$line") +done < <(ls -a) + +check_diff(){ + local miss=() extra=() + for i in "${MERGE_OBJECTS_LIST[@]}";do + [[ ! " ${REAL_ITEMS[@]} " =~ " ${i} " ]] && miss+=("$i") + done + for i in "${REAL_ITEMS[@]}";do + [[ ! " ${MERGE_OBJECTS_LIST[@]} " =~ " ${i} " ]] && extra+=("$i") + done + if [[ ${#miss[@]} -gt 0 || ${#extra[@]} -gt 0 ]];then + echo "本地目录结构不一致,终止运行" + exit 1 + fi +} +check_diff + +echo -e "#@@@ 按时间获取最新标签合并模块源码 @@@#" + +# 应用型模块 +MERGE_APP_PROJECT_LIST=(WinBoLL) +echo -e "---------- 应用型模块 ----------" +for name in "${MERGE_APP_PROJECT_LIST[@]}";do + low_name=$(echo "$name" | tr 'A-Z' 'a-z') + tag=$(get_latest_module_tag "${low_name}") + if [[ -z "${tag}" ]];then + echo "跳过 ${low_name}:无远程标签" + continue + fi + commit=$(get_commit_from_tag "${tag}") + if [[ -z "${commit}" ]];then + echo "跳过 ${low_name}:标签无有效提交点" + continue + fi + echo "模块:${low_name} 最新时间标签:${tag} 提交ID:${commit}" + # 强制拉取覆盖 + git checkout -f "${tag}" -- "${low_name}" + git add "${low_name}" + git commit -m "合并模块${name} 同步最新时间标签${tag}" +done + +# 类库模块 +MERGE_LIB_PROJECT_LIST=(APPBase AES) +echo -e "---------- 类库模块 ----------" +for name in "${MERGE_LIB_PROJECT_LIST[@]}";do + low_name=$(echo "$name" | tr 'A-Z' 'a-z') + tag=$(get_latest_module_tag "${low_name}") + if [[ -z "${tag}" ]];then + echo "跳过 ${low_name}:无远程标签" + continue + fi + commit=$(get_commit_from_tag "${tag}") + if [[ -z "${commit}" ]];then + echo "跳过 ${low_name}:标签无有效提交点" + continue + fi + echo "模块:${low_name} 最新时间标签:${tag} 提交ID:${commit}" + git checkout -f "${tag}" -- "${low_name}" "lib${low_name}" + git add "${low_name}" "lib${low_name}" + git commit -m "合并模块${name} 同步最新时间标签${tag}" +done + +echo "全部模块合并执行完毕" +echo "执行推送:git push" +git push diff --git a/.winboll/bashPublishAPKAddTagInTermux.sh b/.winboll/bashPublishAPKAddTagInTermux.sh new file mode 100644 index 0000000..bf9e239 --- /dev/null +++ b/.winboll/bashPublishAPKAddTagInTermux.sh @@ -0,0 +1,228 @@ +#!/usr/bin/bash +# ============================================================================== +# WinBoLL 应用发布脚本 +# 功能:检查Git源码状态 → 编译Stage Release包 → 添加WinBoLL标签 → 提交并推送源码 +# 依赖:build.properties、app_update_description.txt(项目根目录下) +# 使用:./script_name.sh +# 作者:豆包&ZhanGSKen +# ============================================================================== + +# ==================== 常量定义 ==================== +# 脚本退出码 +EXIT_CODE_SUCCESS=0 +EXIT_CODE_ERR_NO_APP_NAME=2 +EXIT_CODE_ERR_WORK_DIR=1 +EXIT_CODE_ERR_GIT_CHECK=1 +EXIT_CODE_ERR_ADD_WINBOLL_TAG=1 + +# Gradle 任务(正式发布) +GRADLE_TASK_PUBLISH="assembleStageRelease" +# Gradle 任务(调试用,注释备用) +# GRADLE_TASK_DEBUG="assembleBetaDebug" + +# aapt2本地覆盖参数 +AAPT2_OVERRIDE_ARG="-Pandroid.aapt2FromMavenOverride=/data/data/com.termux/files/usr/bin/aapt2" +# 禁用Gradle守护进程 +GRADLE_NO_DAEMON="--no-daemon" + +# ==================== 函数定义 ==================== +# 检查Git源码是否已完全提交(无未提交变更) +# 返回值:0=已完全提交,1=存在未提交变更 +function checkGitSources() { + # 配置Git安全目录(解决权限问题) + git config --global --add safe.directory "$(pwd)" + + # 检查是否有未提交的变更 + if [[ -n $(git diff --stat) ]]; then + echo "[ERROR] Git源码存在未提交变更,请先提交所有修改!" + return 1 + fi + + echo "[INFO] Git源码检查通过:所有变更已提交。" + return 0 +} + +# 询问是否添加GitHub Workflows标签(当前逻辑注释,保留扩展能力) +# 返回值:1=用户选择是,0=用户选择否 +function askAddWorkflowsTag() { + read -p "是否添加GitHub Workflows标签?(Y/n) " answer + if [[ $answer =~ ^[Yy]$ ]]; then + return 1 + else + return 0 + fi +} + +# 添加WinBoLL正式标签 +# 参数:$1=应用名称(项目根目录名) +# 返回值:0=标签添加成功,1=标签已存在/添加失败 +function addWinBoLLTag() { + local app_name=$1 + local build_prop_path="${app_name}/build.properties" + + # 从build.properties中提取publishVersion + local publish_version=$(grep -o "publishVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}') + if [[ -z ${publish_version} ]]; then + echo "[ERROR] 未从${build_prop_path}中提取到publishVersion配置!" + return 1 + fi + echo "[INFO] 从${build_prop_path}读取到publishVersion:${publish_version}" + + # 构造WinBoLL标签(格式:-v) + local tag="${app_name}-v${publish_version}" + echo "[INFO] 准备添加WinBoLL标签:${tag}" + + # 检查标签是否已存在 + if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then + echo "[ERROR] WinBoLL标签${tag}已存在!" + return 1 + fi + + # 添加带注释的标签(注释来自app_update_description.txt) + git tag -a "${tag}" -F "${app_name}/app_update_description.txt" + echo "[INFO] WinBoLL标签${tag}添加成功!" + return 0 +} + +# 添加GitHub Workflows Beta标签(当前逻辑注释,保留扩展能力) +# 参数:$1=应用名称(项目根目录名) +# 返回值:0=标签添加成功,1=标签已存在/添加失败 +function addWorkflowsTag() { + local app_name=$1 + local build_prop_path="${app_name}/build.properties" + + # 从build.properties中提取baseBetaVersion + local base_beta_version=$(grep -o "baseBetaVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}') + if [[ -z ${base_beta_version} ]]; then + echo "[ERROR] 未从${build_prop_path}中提取到baseBetaVersion配置!" + return 1 + fi + echo "[INFO] 从${build_prop_path}读取到baseBetaVersion:${base_beta_version}" + + # 构造Workflows标签(格式:-v-beta) + local tag="${app_name}-v${base_beta_version}-beta" + echo "[INFO] 准备添加Workflows标签:${tag}" + + # 检查标签是否已存在 + if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then + echo "[ERROR] Workflows标签${tag}已存在!" + return 1 + fi + + # 添加带注释的标签(注释来自app_update_description.txt) + git tag -a "${tag}" -F "${app_name}/app_update_description.txt" + echo "[INFO] Workflows标签${tag}添加成功!" + return 0 +} + +# ==================== 主流程开始 ==================== +echo "=============================================" +echo " WinBoLL 应用发布脚本" +echo "=============================================" + +# 1. 检查应用名称参数是否指定 +if [ -z "$1" ]; then + echo "[ERROR] 未指定应用名称!使用方式:${0} " + exit ${EXIT_CODE_ERR_NO_APP_NAME} +fi +APP_NAME=$1 +echo "[INFO] 待发布应用名称:${APP_NAME}" + +# 2. 检查并切换到项目根目录(确保build.properties存在) +echo "[INFO] 当前工作目录:$(pwd)" +if [[ ! -e "${APP_NAME}/build.properties" ]]; then + echo "[WARNING] 当前目录不存在${APP_NAME}/build.properties,尝试切换到上级目录..." + cd .. + echo "[INFO] 切换后工作目录:$(pwd)" +fi + +# 验证最终工作目录是否正确 +if [[ ! -e "${APP_NAME}/build.properties" ]]; then + echo "[ERROR] 工作目录错误!${APP_NAME}/build.properties 文件不存在。" + exit ${EXIT_CODE_ERR_WORK_DIR} +fi +echo "[INFO] 工作目录验证通过:${APP_NAME}/build.properties 存在。" + +# 3. 检查Git源码状态 +echo "---------------------------------------------" +echo " 步骤1:检查Git源码状态" +echo "---------------------------------------------" +checkGitSources +if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then + echo "[ERROR] Git源码检查失败,脚本终止!" + exit ${EXIT_CODE_ERR_GIT_CHECK} +fi + +# 4. 编译Stage Release版本APK(携带aapt2覆盖参数 + --no-daemon) +echo "---------------------------------------------" +echo " 步骤2:编译Stage Release APK" +echo "---------------------------------------------" +echo "[INFO] 开始执行Gradle任务:${GRADLE_TASK_PUBLISH}" +# 调试用(注释正式任务,启用调试任务) +# bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :${APP_NAME}:${GRADLE_TASK_DEBUG} +bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :${APP_NAME}:${GRADLE_TASK_PUBLISH} + +if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then + echo "[ERROR] Gradle编译任务失败!" + exit 1 +fi +echo "[INFO] Stage Release APK编译成功!" + +# 5. 添加WinBoLL正式标签 +echo "---------------------------------------------" +echo " 步骤3:添加WinBoLL标签" +echo "---------------------------------------------" +addWinBoLLTag ${APP_NAME} +if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then + echo "[ERROR] WinBoLL标签添加失败,脚本终止!" + exit ${EXIT_CODE_ERR_ADD_WINBOLL_TAG} +fi + +# 6. (可选)添加GitHub Workflows标签(当前逻辑注释,保留扩展能力) +# echo "---------------------------------------------" +# echo " 步骤4:添加Workflows标签(可选)" +# echo "---------------------------------------------" +# echo "是否添加GitHub Workflows Beta标签?(Y/n) " +# askAddWorkflowsTag +# nAskAddWorkflowsTag=$? +# if [[ ${nAskAddWorkflowsTag} -eq 1 ]]; then +# addWorkflowsTag ${APP_NAME} +# if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then +# echo "[ERROR] Workflows标签添加失败,脚本终止!" +# exit 1 +# fi +# fi + +# 7. 清理更新描述文件 +echo "---------------------------------------------" +echo " 步骤5:清理更新描述文件" +echo "---------------------------------------------" +echo "" > "${APP_NAME}/app_update_description.txt" +echo "[INFO] 已清空${APP_NAME}/app_update_description.txt" + +# 8. 提交并推送源码与标签 +echo "---------------------------------------------" +echo " 步骤6:提交并推送源码" +echo "---------------------------------------------" +git add . +git commit -m "<${APP_NAME}> 开始新的Stage版本开发。" +echo "[INFO] 源码提交成功,开始推送..." + +# 推送源码到远程仓库 +git push origin +# 推送标签到远程仓库 +git push origin --tags + +if [[ $? -eq ${EXIT_CODE_SUCCESS} ]]; then + echo "[INFO] 源码与标签推送成功!" +else + echo "[ERROR] 源码与标签推送失败!" + exit 1 +fi + +# ==================== 主流程结束 ==================== +echo "=============================================" +echo " WinBoLL 应用发布完成!" +echo "=============================================" +exit ${EXIT_CODE_SUCCESS} + diff --git a/.winboll/bashPublishLIBAddTagInTermux.sh b/.winboll/bashPublishLIBAddTagInTermux.sh new file mode 100644 index 0000000..b151747 --- /dev/null +++ b/.winboll/bashPublishLIBAddTagInTermux.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +# aapt2本地覆盖参数 +AAPT2_OVERRIDE_ARG="-Pandroid.aapt2FromMavenOverride=/data/data/com.termux/files/usr/bin/aapt2" +# Gradle禁用守护进程参数 +GRADLE_NO_DAEMON="--no-daemon" + +# 检查是否指定了将要发布的类库名称 +# 使用 `-z` 命令检查变量是否为空 +if [ -z "$1" ]; then + echo "No Library name specified : $0" + exit 2 +fi + +## 正式发布使用 +git pull && bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :$1:publishReleasePublicationToWinBoLLReleaseRepository && bash .winboll/bashCommitLibReleaseBuildFlagInfo.sh $1 + +## 调试使用 +#bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :$1:publishSnapshotWinBoLLPublicationToWinBoLLSnapshotRepository && bash .winboll/bashCommitLibReleaseBuildFlagInfo.sh $1 + diff --git a/.winboll/winboll_app_build.gradle b/.winboll/winboll_app_build.gradle index 57b6ba7..23fafa7 100644 --- a/.winboll/winboll_app_build.gradle +++ b/.winboll/winboll_app_build.gradle @@ -122,7 +122,6 @@ android { // 如果正在调试,就拷贝到 WinBoLL 备份管理文件夹 // if(variant.flavorName == "beta"&&variant.buildType.name == "debug"){ - //File outBuildBckDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/${variant.buildType.name}") File outBuildBckDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}") // 创建目标路径目录 if(!outBuildBckDir.exists()) { @@ -130,6 +129,7 @@ android { println "Output Folder Created.(WinBoLLStudio) : " + outBuildBckDir.getAbsolutePath() } if(outBuildBckDir.exists()) { + def targetApkFile = new File(outBuildBckDir, outputFileName) copy{ from file.outputFile into outBuildBckDir @@ -138,6 +138,14 @@ android { } println "Output APK (WinBoLLStudio): " + outBuildBckDir.getAbsolutePath() + "/${outputFileName}" } + // ========== 设置文件权限为775 ========== + if(targetApkFile.exists()){ + exec { + commandLine 'chmod', '775', targetApkFile.absolutePath + } + println "Set file permission to 775 : ${targetApkFile.absolutePath}" + } + // 检查编译标志位配置 assert (winbollBuildProps['buildCount'] != null) assert (winbollBuildProps['libraryProject'] != null) @@ -160,8 +168,7 @@ android { assert(libraryProjectBuildPropsFile.exists()) java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath(); java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath(); - // 使用copyTo()方法复制文件,如果目标文件存在会被覆盖,可选参数可以选择不覆盖 - java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING); + java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING); println "\n\n>>> Library Project build.properties saved.\n\n"; } @@ -172,16 +179,12 @@ android { // if(variant.flavorName == "stage"&&variant.buildType.name == "release"){ // 发布 APK 文件 - // - // 截取版本号的版本字段为短版本名 String szVersionName = "${versionName}" String[] szlistTemp = szVersionName.split("-") String szShortVersionName = szlistTemp[0] - //String szCommonTagAPKName = "${rootProject.name}_" + szShortVersionName + ".apk" String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk" println "CommonTagAPKName is : " + szCommonTagAPKName - //File outTagDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/tag/") File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/tag/") // 创建目标路径目录 if(!outTagDir.exists()) { @@ -192,12 +195,10 @@ android { if(outTagDir.exists()) { File targetAPK = new File(outTagDir, "${szCommonTagAPKName}") if(targetAPK.exists()) { - // 标签版本APK文件已经存在,构建拷贝任务停止 assert (!targetAPK.exists()) - // 可选择删除并继续输出APK文件 - //delete targetAPK } - // 复制一个备份 + // 复制完整版APK + def fullApkFile = new File(outTagDir, outputFileName) copy{ from file.outputFile into outTagDir @@ -206,7 +207,16 @@ android { } println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}" } - // 复制一个并重命名为短版本名 + // 设置权限775。 + if(fullApkFile.exists()){ + exec { + commandLine 'chmod', '775', fullApkFile.absolutePath + } + println "Set file permission to 775 : ${fullApkFile.absolutePath}" + } + + // 复制短版本名APK + def shortApkFile = new File(outTagDir, szCommonTagAPKName) copy{ from file.outputFile into outTagDir @@ -215,6 +225,14 @@ android { } println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}" } + // 设置权限775。 + if(shortApkFile.exists()){ + exec { + commandLine 'chmod', '775', shortApkFile.absolutePath + } + println "Set file permission to 775 : ${shortApkFile.absolutePath}" + } + // 检查编译标志位配置 assert (winbollBuildProps['stageCount'] != null) assert (winbollBuildProps['publishVersion'] != null) @@ -239,14 +257,11 @@ android { fos.close(); if(winbollBuildProps['libraryProject'] != "") { - // 如果应用 build.properties 文件设置了类库模块项目文件名 - // 就拷贝一份新的编译标志配置到类库项目文件夹 File libraryProjectBuildPropsFile = new File("$RootProjectDir/" + winbollBuildProps['libraryProject'] + "/build.properties") assert(winbollBuildPropsFile.exists()) assert(libraryProjectBuildPropsFile.exists()) java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath(); java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath(); - // 使用copyTo()方法复制文件,如果目标文件存在会被覆盖,可选参数可以选择不覆盖 java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING); } @@ -263,17 +278,12 @@ android { // 如果正在调试发布版,就只生成和输出APK文件,不处理 Git 仓库提交与更新问题。 // if(variant.flavorName == "stage"&&variant.buildType.name == "debug"){ - // 发布 APK 文件 - // - // 截取版本号的版本字段为短版本名 String szVersionName = "${versionName}" String[] szlistTemp = szVersionName.split("-") String szShortVersionName = szlistTemp[0] - //String szCommonTagAPKName = "${rootProject.name}_" + szShortVersionName + ".apk" String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk" println "CommonTagAPKName is : " + szCommonTagAPKName - //File outTagDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/tag/") File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}/") // 创建目标路径目录 if(!outTagDir.exists()) { @@ -284,13 +294,11 @@ android { if(outTagDir.exists()) { File targetAPK = new File(outTagDir, "${szCommonTagAPKName}") if(targetAPK.exists()) { - // 标签版本APK文件已经存在,构建拷贝任务停止 println '如果是在调试 Stage 版应用包构建,请删除(注:在debug目录)现有的 Stage 应用包('+targetAPK.getAbsolutePath()+')。再编译一次。' assert (!targetAPK.exists()) - // 可选择删除并继续输出APK文件 - //delete targetAPK } - // 复制一个备份 + // 复制完整版APK + def debugFullApk = new File(outTagDir, outputFileName) copy{ from file.outputFile into outTagDir @@ -299,7 +307,16 @@ android { } println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}" } - // 复制一个并重命名为短版本名 + // 权限设为775。 + if(debugFullApk.exists()){ + exec { + commandLine 'chmod', '775', debugFullApk.absolutePath + } + println "Set file permission to 775 : ${debugFullApk.absolutePath}" + } + + // 复制短版本名APK + def debugShortApk = new File(outTagDir, szCommonTagAPKName) copy{ from file.outputFile into outTagDir @@ -308,8 +325,13 @@ android { } println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}" } - - //不保存编译标志配置 + // 权限设为775 + if(debugShortApk.exists()){ + exec { + commandLine 'chmod', '775', debugShortApk.absolutePath + } + println "Set file permission to 775 : ${debugShortApk.absolutePath}" + } } } @@ -328,6 +350,13 @@ android { } println "Output APK (Common): " + outCommonDir.getAbsolutePath() + "/${commandAPKName}" } + // 额外输出文件设置775权限 + if(apkFile.exists()){ + exec { + commandLine 'chmod', '775', apkFile.absolutePath + } + println "Set file permission to 775 : ${apkFile.absolutePath}" + } } }