mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-27 17:20:06 +08:00
add usage: BUILDJ_JAVA=1.8 BUILDJ_BUILDER=maven3.5.2 buildj
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -294,6 +294,33 @@ fn process_envs(the_env: &mut HashMap<String, String>, build_json_object: &json:
|
||||
}
|
||||
|
||||
fn read_build_json_object() -> Option<json::JsonValue> {
|
||||
if (*JAVA_VERSION).is_some() || (*BUILDER_VERSION).is_some() {
|
||||
let mut build_json_object = object!{};
|
||||
if (*JAVA_VERSION).is_some() {
|
||||
build_json_object["java"] = (*JAVA_VERSION).as_ref().unwrap().to_string().into();
|
||||
}
|
||||
if (*BUILDER_VERSION).is_some() {
|
||||
let builder_version = (*BUILDER_VERSION).as_ref().unwrap().to_string();
|
||||
if builder_version.starts_with("gradle") {
|
||||
build_json_object["builder"] = object! {
|
||||
"name" => "gradle",
|
||||
"version" => builder_version[6..],
|
||||
};
|
||||
} else if builder_version.starts_with("maven") {
|
||||
build_json_object["builder"] = object! {
|
||||
"name" => "maven",
|
||||
"version" => builder_version[5..],
|
||||
};
|
||||
} else {
|
||||
print_message(MessageType::WARN, &format!("Unknown builder: {}", builder_version));
|
||||
}
|
||||
}
|
||||
if *VERBOSE {
|
||||
print_message(MessageType::DEBUG, &format!("Use env configed build.json: {}", json::stringify(build_json_object.clone())));
|
||||
}
|
||||
return Some(build_json_object);
|
||||
}
|
||||
|
||||
let build_json = match find_build_json() {
|
||||
None => return None,
|
||||
Some(p) => p,
|
||||
|
||||
@@ -7,6 +7,8 @@ lazy_static! {
|
||||
pub static ref NOAUTH: bool = is_env_on("BUILDJ_NOAUTH");
|
||||
pub static ref NOBUILDIN: bool = is_env_on("BUILDJ_NOBUILDIN");
|
||||
pub static ref AUTH_TOKEN: Option<String> = env::var("BUILDJ_AUTH_TOKEN").ok();
|
||||
pub static ref JAVA_VERSION: Option<String> = env::var("BUILDJ_JAVA").ok();
|
||||
pub static ref BUILDER_VERSION: Option<String> = env::var("BUILDJ_BUILDER").ok();
|
||||
}
|
||||
|
||||
pub fn print_usage() {
|
||||
@@ -31,6 +33,7 @@ BUILDJ_VERBOSE=1 buildj - run buildj in verbose mode
|
||||
BUILDJ_NOAUTH=1 buildj - run buildj in no auth mode
|
||||
BUILDJ_JAVA_NAME=jdk-name buildj - assgin java name, e.g. adoptjdk-linux
|
||||
BUILDJ_AUTH_TOKEN=auth-token buildj - assign auth token
|
||||
BUILDJ_JAVA=1.8 BUILDJ_BUILDER=maven3.5.2 buildj - direct run buildj
|
||||
"#);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user