【工具】打包工具优化

dev_chengFeng
gaoxin 2021-05-31 20:24:15 +08:00
parent 081ff4c0d8
commit 595df075ed
1 changed files with 25 additions and 1 deletions

View File

@ -253,8 +253,11 @@ public class AutoPack : EditorWindow
Debug.Log(PackConfig[index][0] + ":母包工程资源替换完成");
// 替换build-id
EditorUtility.DisplayProgressBar("重写AndroidManifest", "", 1f);
RewriteManifest(fromPath + "/src/main/AndroidManifest.xml", toPath + "/src/main/AndroidManifest.xml");
Debug.Log(PackConfig[index][0] + "母包Manifest修改完成");
EditorUtility.ClearProgressBar();
}
private static void RewriteManifest(string f, string t)
{
@ -310,18 +313,39 @@ public class AutoPack : EditorWindow
// 替换配置文件
private static void ReplaceConfigAndVersion(int index)
{
EditorUtility.DisplayProgressBar("替换配置文件", "", 1f);
string toPath = _MomPackPath + PackConfig[index][2] + "/src/main/assets/Android/";
string fromPath = _MomPackPath + PackConfig[index][2] + "/Config/";
File.Copy(fromPath + ConfigFileName, toPath + ConfigFileName, true);
File.Copy(fromPath + VersionFileName, toPath + VersionFileName, true);
Debug.Log(PackConfig[index][0]+":配置文件替换完成");
EditorUtility.ClearProgressBar();
}
// 开始生成apk
private static void StartGradleBuild(int index)
{
GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleDebug");
EditorUtility.DisplayProgressBar("正在生成APK", "", 1f);
string apkPath = _MomPackPath + PackConfig[index][2] + "/APK/";
if (!Directory.Exists(apkPath))
{
Directory.CreateDirectory(apkPath);
}
string time = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
if (!Directory.Exists(apkPath + time))
{
Directory.CreateDirectory(apkPath + time);
}
GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>" + apkPath + time +"/_log.txt");
EditorUtility.DisplayProgressBar("正在导出APK", "", 1f);
string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk";
if (File.Exists(apkFilePath))
{
File.Copy(apkFilePath, apkPath + time + "/" + PackConfig[index][2] + ".apk");
}
Debug.Log(PackConfig[index][0] + ":打包完成");
EditorUtility.ClearProgressBar();
}
//private static void ExportXcode(string _sceneName)