use anyhow::Result;
use std::process::Command;
use crate::commands::build::{build_classpath, check_jars};
use crate::config::load_config;
pub fn run() -> Result<()> {
let config = load_config()?;
check_jars(&config)?;
if !config.dependencies.jars.is_empty() {
info!(
"Including {} dependenc{} in runtime classpath",
config.dependencies.jars.len(),
if config.dependencies.jars.len() == 1 {
"y"
} else {
"ies"
}
);
}
let classpath = build_classpath(&config);
info!("Starting {} ...", config.paths.main_class);
let status = match Command::new("java")
.arg("-cp")
.arg(&classpath)
.arg(&config.paths.main_class)
.status()
{
Ok(status) => status,
Err(_) => {
error!("java could not be started");
}
};
if !status.success() {
error!("Execution failed");
}
Ok(())
}