mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #86383 from m4gr3d/editor_export_specify_java_sdk_path_main
Specify the path to the Java SDK used for the Android gradle build
This commit is contained in:
commit
6fa577cada
5 changed files with 64 additions and 5 deletions
|
@ -2115,8 +2115,17 @@ Ref<Texture2D> EditorExportPlatformAndroid::get_run_icon() const {
|
|||
return run_icon;
|
||||
}
|
||||
|
||||
String EditorExportPlatformAndroid::get_java_path() {
|
||||
String exe_ext;
|
||||
if (OS::get_singleton()->get_name() == "Windows") {
|
||||
exe_ext = ".exe";
|
||||
}
|
||||
String java_sdk_path = EDITOR_GET("export/android/java_sdk_path");
|
||||
return java_sdk_path.path_join("bin/java" + exe_ext);
|
||||
}
|
||||
|
||||
String EditorExportPlatformAndroid::get_adb_path() {
|
||||
String exe_ext = "";
|
||||
String exe_ext;
|
||||
if (OS::get_singleton()->get_name() == "Windows") {
|
||||
exe_ext = ".exe";
|
||||
}
|
||||
|
@ -2128,13 +2137,13 @@ String EditorExportPlatformAndroid::get_apksigner_path(int p_target_sdk, bool p_
|
|||
if (p_target_sdk == -1) {
|
||||
p_target_sdk = DEFAULT_TARGET_SDK_VERSION;
|
||||
}
|
||||
String exe_ext = "";
|
||||
String exe_ext;
|
||||
if (OS::get_singleton()->get_name() == "Windows") {
|
||||
exe_ext = ".bat";
|
||||
}
|
||||
String apksigner_command_name = "apksigner" + exe_ext;
|
||||
String sdk_path = EDITOR_GET("export/android/android_sdk_path");
|
||||
String apksigner_path = "";
|
||||
String apksigner_path;
|
||||
|
||||
Error errn;
|
||||
String build_tools_dir = sdk_path.path_join("build-tools");
|
||||
|
@ -2381,6 +2390,32 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
|
|||
err += TTR("Release keystore incorrectly configured in the export preset.") + "\n";
|
||||
}
|
||||
|
||||
String java_sdk_path = EDITOR_GET("export/android/java_sdk_path");
|
||||
if (java_sdk_path.is_empty()) {
|
||||
err += TTR("A valid Java SDK path is required in Editor Settings.") + "\n";
|
||||
valid = false;
|
||||
} else {
|
||||
// Validate the given path by checking that `java` is present under the `bin` directory.
|
||||
Error errn;
|
||||
// Check for the bin directory.
|
||||
Ref<DirAccess> da = DirAccess::open(java_sdk_path.path_join("bin"), &errn);
|
||||
if (errn != OK) {
|
||||
err += TTR("Invalid Java SDK path in Editor Settings.");
|
||||
err += TTR("Missing 'bin' directory!");
|
||||
err += "\n";
|
||||
valid = false;
|
||||
} else {
|
||||
// Check for the `java` command.
|
||||
String java_path = get_java_path();
|
||||
if (!FileAccess::exists(java_path)) {
|
||||
err += TTR("Unable to find 'java' command using the Java SDK path.");
|
||||
err += TTR("Please check the Java SDK directory specified in Editor Settings.");
|
||||
err += "\n";
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String sdk_path = EDITOR_GET("export/android/android_sdk_path");
|
||||
if (sdk_path.is_empty()) {
|
||||
err += TTR("A valid Android SDK path is required in Editor Settings.") + "\n";
|
||||
|
@ -2918,6 +2953,13 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
|
|||
}
|
||||
}
|
||||
const String assets_directory = get_assets_directory(p_preset, export_format);
|
||||
String java_sdk_path = EDITOR_GET("export/android/java_sdk_path");
|
||||
if (java_sdk_path.is_empty()) {
|
||||
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Java SDK path must be configured in Editor Settings at 'export/android/java_sdk_path'."));
|
||||
return ERR_UNCONFIGURED;
|
||||
}
|
||||
print_verbose("Java sdk path: " + java_sdk_path);
|
||||
|
||||
String sdk_path = EDITOR_GET("export/android/android_sdk_path");
|
||||
if (sdk_path.is_empty()) {
|
||||
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Android SDK path must be configured in Editor Settings at 'export/android/android_sdk_path'."));
|
||||
|
@ -2968,8 +3010,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
|
|||
print_verbose("Storing command line flags...");
|
||||
store_file_at_path(assets_directory + "/_cl_", command_line_flags);
|
||||
|
||||
print_verbose("Updating JAVA_HOME environment to " + java_sdk_path);
|
||||
OS::get_singleton()->set_environment("JAVA_HOME", java_sdk_path);
|
||||
|
||||
print_verbose("Updating ANDROID_HOME environment to " + sdk_path);
|
||||
OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path); //set and overwrite if required
|
||||
OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path);
|
||||
String build_command;
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
@ -3032,6 +3077,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
|
|||
String combined_android_dependencies_maven_repos = String("|").join(android_dependencies_maven_repos);
|
||||
|
||||
List<String> cmdline;
|
||||
cmdline.push_back("validateJavaVersion");
|
||||
if (clean_build_required) {
|
||||
cmdline.push_back("clean");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue