Files
RustNotMC/crates/horizon-prepare/tests/support/java_probe.rs
T
SashegDev 874b6f20c2 Клиент: начальный импорт кодовой базы
Основа — Horizon (MIT). История апстрима не переносится: этот репозиторий ведёт свою.
2026-10-29 22:04:28 +03:00

22 lines
779 B
Rust

//! A fake Java tool for process-level JDK selection tests; no installed Java is needed.
use std::{env, fs, process};
fn main() {
let executable = env::current_exe().unwrap();
let bin = executable.parent().unwrap();
let tool = executable.file_stem().unwrap().to_str().unwrap();
let version = fs::read_to_string(bin.join(format!("{tool}.version"))).unwrap();
if env::args().nth(1).as_deref() == Some("-version") {
if tool == "javac" {
println!("javac {version}");
} else {
eprintln!("openjdk version \"{version}\"");
}
} else {
println!("{tool} {version}");
}
if let Ok(status) = fs::read_to_string(bin.join(format!("{tool}.exit"))) {
process::exit(status.parse().unwrap());
}
}