use std::fs;
fn gradle_version() -> Option<String> {
let text =
fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/../../gradle.properties")).ok()?;
text.lines()
.find_map(|l| l.trim().strip_prefix("version=").map(|v| v.trim().to_string()))
}
#[test]
fn cargo_version_matches_gradle_properties() {
let Some(gradle) = gradle_version() else {
eprintln!("gradle.properties not reachable (published crate); nothing to cross-check");
return;
};
let cargo = env!("CARGO_PKG_VERSION");
assert_eq!(
cargo, gradle,
"\n\nCargo.toml version ({cargo}) does not match gradle.properties version ({gradle}).\n\
gradle.properties is the single source of truth; the committed Cargo.toml must be kept in\n\
lockstep, or the wrapper<->libccl version-skew check fails every Rust test with an\n\
unrelated-looking runtime error. Fix:\n\n\
\x20 ./wrappers/rust/scripts/set-crate-version.sh {gradle}\n\n\
and commit Cargo.toml + Cargo.lock.\n"
);
}