mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-29 18:30:05 +08:00
ref print_*
This commit is contained in:
24
src/jdk.rs
24
src/jdk.rs
@@ -6,13 +6,15 @@ use std::{
|
|||||||
path::Path,
|
path::Path,
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
use rust_util::{
|
||||||
use super::{
|
iff,
|
||||||
rust_util::{
|
util_os::*,
|
||||||
iff,
|
util_msg::{
|
||||||
util_os::*,
|
print_error,
|
||||||
util_msg::*,
|
print_debug,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
use super::{
|
||||||
local_util,
|
local_util,
|
||||||
tool,
|
tool,
|
||||||
misc::*,
|
misc::*,
|
||||||
@@ -65,7 +67,7 @@ pub fn get_cloud_java(version: &str) -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_message(MessageType::ERROR, &format!("Get java failed, version: {}", version));
|
print_error(&format!("Get java failed, version: {}", version));
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ pub fn get_macos_java_home(version: &str) -> Option<String> {
|
|||||||
let output = Command::new(MACOS_LIBEXEC_JAVAHOME).arg("-version").arg(version).output().ok()?;
|
let output = Command::new(MACOS_LIBEXEC_JAVAHOME).arg("-version").arg(version).output().ok()?;
|
||||||
let output_in_utf8 = str::from_utf8(&output.stderr).ok()?;
|
let output_in_utf8 = str::from_utf8(&output.stderr).ok()?;
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("java_home outputs: {}", output_in_utf8));
|
print_debug(&format!("java_home outputs: {}", output_in_utf8));
|
||||||
}
|
}
|
||||||
if output_in_utf8.contains("Unable to find any JVMs") {
|
if output_in_utf8.contains("Unable to find any JVMs") {
|
||||||
None
|
None
|
||||||
@@ -92,7 +94,7 @@ pub fn get_local_java_home(version: &str) -> Option<String> {
|
|||||||
if let Ok(dir_entry) = path {
|
if let Ok(dir_entry) = path {
|
||||||
if let Some(p)= dir_entry.path().to_str() {
|
if let Some(p)= dir_entry.path().to_str() {
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("Try match path: {}", p));
|
print_debug(&format!("Try match path: {}", p));
|
||||||
}
|
}
|
||||||
let mut path_name = p;
|
let mut path_name = p;
|
||||||
if p.ends_with('/') {
|
if p.ends_with('/') {
|
||||||
@@ -109,7 +111,7 @@ pub fn get_local_java_home(version: &str) -> Option<String> {
|
|||||||
};
|
};
|
||||||
if let Some(matched_path) = matched_path_opt {
|
if let Some(matched_path) = matched_path_opt {
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("Matched JDK path found: {}", matched_path));
|
print_debug(&format!("Matched JDK path found: {}", matched_path));
|
||||||
}
|
}
|
||||||
return if local_util::is_path_exists(matched_path, "Contents/Home") {
|
return if local_util::is_path_exists(matched_path, "Contents/Home") {
|
||||||
Some(format!("{}/{}", matched_path, "Contents/Home"))
|
Some(format!("{}/{}", matched_path, "Contents/Home"))
|
||||||
@@ -126,7 +128,7 @@ pub fn get_local_java_home(version: &str) -> Option<String> {
|
|||||||
pub fn extract_jdk_and_wait(file_name: &str) {
|
pub fn extract_jdk_and_wait(file_name: &str) {
|
||||||
if let Ok(local_java_home_base_dir) = local_util::get_user_home_dir(LOCAL_JAVA_HOME_BASE_DIR) {
|
if let Ok(local_java_home_base_dir) = local_util::get_user_home_dir(LOCAL_JAVA_HOME_BASE_DIR) {
|
||||||
local_util::extract_package_and_wait(&local_java_home_base_dir, file_name).unwrap_or_else(|err| {
|
local_util::extract_package_and_wait(&local_java_home_base_dir, file_name).unwrap_or_else(|err| {
|
||||||
print_message(MessageType::ERROR, &format!("Extract file: {}, failed: {}", file_name, err));
|
print_error(&format!("Extract file: {}, failed: {}", file_name, err));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user