Skip to content

Commit

Permalink
improve java version recognition and fix java welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
JsLth committed Sep 18, 2024
1 parent a7ea0ca commit b5c860d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ escape_cli <- function(x) {

cli_once <- function(name, msg, verbose) {
if (!isTRUE(get0(name, envir = ors_cache))) {
ors_cli(info = list(c("i" = msg)))
ors_cli(info = list(msg))
assign(name, TRUE, envir = ors_cache)
}
}
16 changes: 10 additions & 6 deletions R/jar.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,21 @@ get_java_version <- function(verbose) {
abort(msg, class = "java_missing_error", call = NULL)
}

version <- callr::run("java", "-version", error_on_status = TRUE)
cli_once("java_msg", msg = version$stderr, verbose = verbose)
version$stderr
version <- callr::run("java", "-version", error_on_status = TRUE)$stderr
version <- gsub("\n", "\f", gsub("\r", "", version))
cli_once("java_msg", msg = version, verbose = verbose)
version
}


# regex borrowed from https://github.com/e-kotov/rJavaEnv/blob/main/R/java_env.R
check_jdk_version <- function(verbose) {
version <- get_java_version(verbose)
version <- strsplit(version, "\n")[[1]]
version <- version[startsWith(version, "java version")]
version <- regex_match(version, dQuote("([0-9\\.]+).*", q = FALSE))[[1]][2]
version <- regex_match(
version,
"(?<=openjdk|java version \\\")[0-9]{1,2}(?=\\.)",
perl = TRUE
)[[1]]

if (!minimum_version(version, "17")) {
url <- "https://www.oracle.com/de/java/technologies/downloads/"
Expand Down

0 comments on commit b5c860d

Please sign in to comment.