diff options
Diffstat (limited to 'src/graphmarkup.rs')
-rw-r--r-- | src/graphmarkup.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/graphmarkup.rs b/src/graphmarkup.rs index 78ffe89..f5637dc 100644 --- a/src/graphmarkup.rs +++ b/src/graphmarkup.rs @@ -29,6 +29,13 @@ pub struct MarkupOpts { env = "SUBPLOT_PLANTUML_JAR_PATH" )] plantuml_jar_path: Option<PathBuf>, + #[structopt( + long = "java", + help = "Path to Java executable (note, effectively overrides JAVA_HOME if set to an absolute path)", + name = "JAVA_PATH", + env = "SUBPLOT_JAVA_PATH" + )] + java_path: Option<PathBuf>, } impl MarkupOpts { @@ -40,13 +47,17 @@ impl MarkupOpts { if let Some(plantuml_path) = &self.plantuml_jar_path { *PLANTUML_JAR_PATH.lock().unwrap() = plantuml_path.clone(); } + if let Some(java_path) = &self.java_path { + *JAVA_PATH.lock().unwrap() = java_path.clone(); + } } } lazy_static! { - static ref DOT_PATH: Mutex<PathBuf> = Mutex::new("dot".into()); + static ref DOT_PATH: Mutex<PathBuf> = Mutex::new(env!("BUILTIN_DOT_PATH").into()); static ref PLANTUML_JAR_PATH: Mutex<PathBuf> = - Mutex::new("/usr/share/plantuml/plantuml.jar".into()); + Mutex::new(env!("BUILTIN_PLANTUML_JAR_PATH").into()); + static ref JAVA_PATH: Mutex<PathBuf> = Mutex::new(env!("BUILTIN_JAVA_PATH").into()); } /// A code block with markup for a graph. @@ -181,7 +192,7 @@ impl PlantumlMarkup { impl GraphMarkup for PlantumlMarkup { fn as_svg(&self) -> Result<Vec<u8>> { - let mut cmd = Command::new("java"); + let mut cmd = Command::new(JAVA_PATH.lock().unwrap().clone()); cmd.arg("-Djava.awt.headless=true") .arg("-jar") .arg(PLANTUML_JAR_PATH.lock().unwrap().clone()) |