Clean up the build commands used by the editor for gradle builds

This commit is contained in:
Fredia Huya-Kouadio 2024-04-30 14:09:24 -07:00 committed by Fredia Huya-Kouadio
parent 0342900b77
commit d38c5b6737
3 changed files with 33 additions and 64 deletions

View File

@ -3365,18 +3365,17 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
} }
List<String> copy_args; List<String> copy_args;
String copy_command; String copy_command = "copyAndRenameBinary";
if (export_format == EXPORT_FORMAT_AAB) {
copy_command = vformat("copyAndRename%sAab", build_type);
} else if (export_format == EXPORT_FORMAT_APK) {
copy_command = vformat("copyAndRename%sApk", build_type);
}
copy_args.push_back(copy_command); copy_args.push_back(copy_command);
copy_args.push_back("-p"); // argument to specify the start directory. copy_args.push_back("-p"); // argument to specify the start directory.
copy_args.push_back(build_path); // start directory. copy_args.push_back(build_path); // start directory.
copy_args.push_back("-Pexport_build_type=" + build_type.to_lower());
String export_format_arg = export_format == EXPORT_FORMAT_AAB ? "aab" : "apk";
copy_args.push_back("-Pexport_format=" + export_format_arg);
String export_filename = p_path.get_file(); String export_filename = p_path.get_file();
String export_path = p_path.get_base_dir(); String export_path = p_path.get_base_dir();
if (export_path.is_relative_path()) { if (export_path.is_relative_path()) {

View File

@ -210,70 +210,24 @@ android {
} }
} }
task copyAndRenameDebugApk(type: Copy) { task copyAndRenameBinary(type: Copy) {
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files // The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files
// and directories. Otherwise this check may cause permissions access failures on Windows // and directories. Otherwise this check may cause permissions access failures on Windows
// machines. // machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation") doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/apk/debug/android_debug.apk" String exportPath = getExportPath()
into getExportPath() String exportFilename = getExportFilename()
rename "android_debug.apk", getExportFilename() String exportBuildType = getExportBuildType()
} String exportFormat = getExportFormat()
task copyAndRenameDevApk(type: Copy) { boolean isAab = exportFormat == "aab"
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files String sourceFilepath = isAab ? "$buildDir/outputs/bundle/$exportBuildType/build-${exportBuildType}.aab" : "$buildDir/outputs/apk/$exportBuildType/android_${exportBuildType}.apk"
// and directories. Otherwise this check may cause permissions access failures on Windows String sourceFilename = isAab ? "build-${exportBuildType}.aab" : "android_${exportBuildType}.apk"
// machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/apk/dev/android_dev.apk" from sourceFilepath
into getExportPath() into exportPath
rename "android_dev.apk", getExportFilename() rename sourceFilename, exportFilename
}
task copyAndRenameReleaseApk(type: Copy) {
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files
// and directories. Otherwise this check may cause permissions access failures on Windows
// machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/apk/release/android_release.apk"
into getExportPath()
rename "android_release.apk", getExportFilename()
}
task copyAndRenameDebugAab(type: Copy) {
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files
// and directories. Otherwise this check may cause permissions access failures on Windows
// machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/bundle/debug/build-debug.aab"
into getExportPath()
rename "build-debug.aab", getExportFilename()
}
task copyAndRenameDevAab(type: Copy) {
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files
// and directories. Otherwise this check may cause permissions access failures on Windows
// machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/bundle/dev/build-dev.aab"
into getExportPath()
rename "build-dev.aab", getExportFilename()
}
task copyAndRenameReleaseAab(type: Copy) {
// The 'doNotTrackState' is added to disable gradle's up-to-date checks for output files
// and directories. Otherwise this check may cause permissions access failures on Windows
// machines.
doNotTrackState("No need for up-to-date checks for the copy-and-rename operation")
from "$buildDir/outputs/bundle/release/build-release.aab"
into getExportPath()
rename "build-release.aab", getExportFilename()
} }
/** /**

View File

@ -223,6 +223,22 @@ ext.getExportFilename = {
return exportFilename return exportFilename
} }
ext.getExportBuildType = {
String exportBuildType = project.hasProperty("export_build_type") ? project.property("export_build_type") : ""
if (exportBuildType == null || exportBuildType.isEmpty()) {
exportBuildType = "debug"
}
return exportBuildType
}
ext.getExportFormat = {
String exportFormat = project.hasProperty("export_format") ? project.property("export_format") : ""
if (exportFormat == null || exportFormat.isEmpty()) {
exportFormat = "apk"
}
return exportFormat
}
/** /**
* Parse the project properties for the 'plugins_maven_repos' property and return the list * Parse the project properties for the 'plugins_maven_repos' property and return the list
* of maven repos. * of maven repos.