1
0
mirror of https://github.com/jht5945/buildj.git synced 2025-12-29 10:20:04 +08:00

use consts

This commit is contained in:
2019-08-11 00:00:26 +08:00
parent f5361cda7c
commit 00ef6749f2

View File

@@ -24,6 +24,9 @@ use super::{
misc::*, misc::*,
}; };
const PATH: &str = "PATH";
const JAVA_HOME: &str = "JAVA_HOME";
const OPENJDK_MACOS: &str = "openjdk-osx"; const OPENJDK_MACOS: &str = "openjdk-osx";
const JDK_LINUX: &str = "jdk-linux"; const JDK_LINUX: &str = "jdk-linux";
const OPENJDK_LINUX: &str = "openjdk-linux"; const OPENJDK_LINUX: &str = "openjdk-linux";
@@ -149,16 +152,16 @@ pub fn get_env_with_java_home(java_home: &str) -> HashMap<String, String> {
let mut new_env: HashMap<String, String> = HashMap::new(); let mut new_env: HashMap<String, String> = HashMap::new();
for (key, value) in env::vars() { for (key, value) in env::vars() {
let key_str = key.as_str(); let key_str = key.as_str();
if "JAVA_HOME" == key_str { if JAVA_HOME == key_str {
// IGNORE JAVA_HOME // IGNORE JAVA_HOME
} else if "PATH" == key_str { } else if PATH == key_str {
let path = value.to_string(); let path = value.to_string();
let new_path = format!("{}/bin:{}", java_home, path); let new_path = format!("{}/bin:{}", java_home, path);
new_env.insert("PATH".to_string(), new_path); new_env.insert(PATH.to_string(), new_path);
} else { } else {
new_env.insert(key, value); new_env.insert(key, value);
} }
} }
new_env.insert("JAVA_HOME".to_string(), java_home.to_string()); new_env.insert(JAVA_HOME.to_string(), java_home.to_string());
new_env new_env
} }