mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-29 18:30:05 +08:00
support jdk and openjdk download, update version
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -79,7 +79,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "buildj"
|
name = "buildj"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"json 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"json 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "buildj"
|
name = "buildj"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
23
src/jdk.rs
23
src/jdk.rs
@@ -20,6 +20,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
const OPENJDK_MACOS: &str = "openjdk-osx";
|
const OPENJDK_MACOS: &str = "openjdk-osx";
|
||||||
|
const JDK_LINUX: &str = "jdk-linux";
|
||||||
const OPENJDK_LINUX: &str = "openjdk-linux";
|
const OPENJDK_LINUX: &str = "openjdk-linux";
|
||||||
|
|
||||||
pub const LOCAL_JAVA_HOME_BASE_DIR: &str = ".jssp/jdks";
|
pub const LOCAL_JAVA_HOME_BASE_DIR: &str = ".jssp/jdks";
|
||||||
@@ -41,24 +42,26 @@ pub fn get_cloud_java(version: &str) -> bool {
|
|||||||
if ! is_macos_or_linux() {
|
if ! is_macos_or_linux() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let cloud_java_name = if is_macos() {
|
let cloud_java_names = if is_macos() {
|
||||||
OPENJDK_MACOS
|
vec![OPENJDK_MACOS]
|
||||||
} else if is_linux() {
|
} else if is_linux() {
|
||||||
OPENJDK_LINUX
|
vec![JDK_LINUX, OPENJDK_LINUX]
|
||||||
} else {
|
} else {
|
||||||
""
|
vec![]
|
||||||
};
|
};
|
||||||
let local_java_home_base_dir = match local_util::get_user_home_dir(LOCAL_JAVA_HOME_BASE_DIR) {
|
let local_java_home_base_dir = match local_util::get_user_home_dir(LOCAL_JAVA_HOME_BASE_DIR) {
|
||||||
Err(_) => return false,
|
Err(_) => return false,
|
||||||
Ok(o) => o,
|
Ok(o) => o,
|
||||||
};
|
};
|
||||||
match tool::get_and_extract_tool_package(&local_java_home_base_dir, false, cloud_java_name, version, false) {
|
for i in 0..cloud_java_names.len() {
|
||||||
Err(err) => {
|
let cloud_java_name = cloud_java_names[i];
|
||||||
print_message(MessageType::ERROR, &format!("Get java failed, version: {}, error: {}", version, err));
|
match tool::get_and_extract_tool_package(&local_java_home_base_dir, false, cloud_java_name, version, false) {
|
||||||
return false;
|
Err(_) => (),
|
||||||
},
|
Ok(_) => return true,
|
||||||
Ok(_) => true,
|
}
|
||||||
}
|
}
|
||||||
|
print_message(MessageType::ERROR, &format!("Get java failed, version: {}", version));
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_macos_java_home(version: &str) -> Option<String> {
|
pub fn get_macos_java_home(version: &str) -> Option<String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user