mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-29 10:20:04 +08:00
feat: exit with non 0, when fails
This commit is contained in:
1160
Cargo.lock
generated
1160
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "buildj"
|
name = "buildj"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@@ -12,4 +12,4 @@ urlencoding = "1.1.1"
|
|||||||
dirs = "3.0.1"
|
dirs = "3.0.1"
|
||||||
rust-crypto = "0.2.36"
|
rust-crypto = "0.2.36"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
rust_util = "0.6.15"
|
rust_util = "0.6.22"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{ fs, path::Path };
|
use std::{fs, path::Path};
|
||||||
use rust_util::{ XResult, new_box_ioerror };
|
use rust_util::{XResult, new_box_ioerror};
|
||||||
|
|
||||||
use crate::http::get_url_content;
|
use crate::http::get_url_content;
|
||||||
use crate::misc::VERBOSE;
|
use crate::misc::VERBOSE;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use rust_util::{ XResult, util_io };
|
use rust_util::{XResult, util_io};
|
||||||
|
|
||||||
use crate::misc::VERBOSE;
|
use crate::misc::VERBOSE;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{ collections::HashMap, env, fs, str, path::Path, process::Command };
|
use std::{collections::HashMap, env, fs, str, path::Path, process::Command};
|
||||||
use rust_util::util_os;
|
use rust_util::util_os;
|
||||||
use crate::{ local_util, tool, misc::{ VERBOSE } };
|
use crate::{local_util, tool, misc::VERBOSE};
|
||||||
|
|
||||||
const PATH: &str = "PATH";
|
const PATH: &str = "PATH";
|
||||||
const JAVA_HOME: &str = "JAVA_HOME";
|
const JAVA_HOME: &str = "JAVA_HOME";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{ env, fs::{ self, File }, io::{ Read, ErrorKind }, path::Path, process::Command };
|
use std::{env, fs::{self, File}, io::{Read, ErrorKind}, path::Path, process::Command};
|
||||||
use rust_util::{ XResult, new_box_ioerror, util_io::{ self, DEFAULT_BUF_SIZE, PrintStatusContext } };
|
use rust_util::{XResult, new_box_ioerror, util_io::{self, DEFAULT_BUF_SIZE, PrintStatusContext}};
|
||||||
use crypto::{ digest::Digest, md5::Md5, sha1::Sha1, sha2::{ Sha256, Sha512 } };
|
use crypto::{digest::Digest, md5::Md5, sha1::Sha1, sha2::{Sha256, Sha512}};
|
||||||
|
|
||||||
pub fn get_args_as_vec() -> Vec<String> {
|
pub fn get_args_as_vec() -> Vec<String> {
|
||||||
env::args().collect::<Vec<String>>()
|
env::args().collect::<Vec<String>>()
|
||||||
|
|||||||
29
src/main.rs
29
src/main.rs
@@ -2,14 +2,12 @@
|
|||||||
extern crate json;
|
extern crate json;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate term;
|
|
||||||
extern crate dirs;
|
|
||||||
extern crate crypto;
|
|
||||||
extern crate urlencoding;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rust_util;
|
extern crate rust_util;
|
||||||
|
|
||||||
use std::{ collections::HashMap, fs, process::Command };
|
use std::fs;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::process::{self, Command};
|
||||||
|
|
||||||
pub mod jdk;
|
pub mod jdk;
|
||||||
pub mod local_util;
|
pub mod local_util;
|
||||||
@@ -46,9 +44,9 @@ fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
|
|||||||
if args.len() > 2 {
|
if args.len() > 2 {
|
||||||
cmd.args(&args[2..]);
|
cmd.args(&args[2..]);
|
||||||
}
|
}
|
||||||
run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
if let Err(err) = run_command_and_wait(&mut cmd) {
|
||||||
failure!("Exec java failed: {}", err);
|
failure!("Exec java failed: {}", err);
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -127,9 +125,9 @@ fn do_with_buildin_arg_builder(first_arg: &str, args: &[String], builder_name: &
|
|||||||
for arg in args.iter().skip(from_index) {
|
for arg in args.iter().skip(from_index) {
|
||||||
cmd.arg(&arg);
|
cmd.arg(&arg);
|
||||||
}
|
}
|
||||||
run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
if let Err(err) = run_command_and_wait(&mut cmd) {
|
||||||
failure!("Run build command failed: {}", err);
|
failure!("Run build command failed: {}", err);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
|
fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
|
||||||
@@ -160,9 +158,9 @@ fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
|
|||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args);
|
debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args);
|
||||||
}
|
}
|
||||||
run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
if let Err(err) = run_command_and_wait(&mut cmd) {
|
||||||
failure!("Run xRun command failed: {}", err);
|
failure!("Run xRun command failed: {}", err);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_with_buildin_args(args: &[String]) {
|
fn do_with_buildin_args(args: &[String]) {
|
||||||
@@ -376,7 +374,14 @@ fn main() {
|
|||||||
}
|
}
|
||||||
debugging!("-----END ENVIRONMENT VARIABLES-----");
|
debugging!("-----END ENVIRONMENT VARIABLES-----");
|
||||||
}
|
}
|
||||||
run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
let exit_status = run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
||||||
failure!("Run build command failed: {}", err);
|
failure!("Run build command failed: {}", err);
|
||||||
|
process::exit(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if !exit_status.success() {
|
||||||
|
if let Some(exit_code) = exit_status.code() {
|
||||||
|
process::exit(exit_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{ fs::{ self, File }, path::Path };
|
use std::{fs::{self, File}, path::Path};
|
||||||
use rust_util::{ XResult, new_box_ioerror, util_os };
|
use rust_util::{ XResult, new_box_ioerror, util_os};
|
||||||
use crate::{ http, local_util, misc::{ AUTH_TOKEN, VERBOSE, NOAUTH } };
|
use crate::{http, local_util, misc::{AUTH_TOKEN, VERBOSE, NOAUTH}};
|
||||||
|
|
||||||
const M2_HOME: &str = "M2_HOME";
|
const M2_HOME: &str = "M2_HOME";
|
||||||
const MAVEN_HOME: &str = "MAVEN_HOME";
|
const MAVEN_HOME: &str = "MAVEN_HOME";
|
||||||
|
|||||||
Reference in New Issue
Block a user