Skip to content

Commit

Permalink
Merge pull request #49 from e-kotov/dev
Browse files Browse the repository at this point in the history
fix java_env_set_session
  • Loading branch information
e-kotov authored Sep 13, 2024
2 parents d7bb4b1 + fd6148f commit 96445db
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
^vignettes/.quarto$
^revdep$
^man/figures/card.png$
^tools$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rJavaEnv
Title: 'Java' Environments for R Projects
Version: 0.2.1
Version: 0.2.1.9000
Authors@R: c(
person("Egor", "Kotov", , "kotov.egor@gmail.com", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-6690-5345")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# rJavaEnv (development version)

# rJavaEnv 0.2.1 (2024-09-03)

* Documentation and description clean-up
Expand Down
7 changes: 4 additions & 3 deletions R/java_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ java_env_set <- function(
java_env_set_session <- function(java_home) {

# check if rJava is installed and alread initialized
if (requireNamespace("rJava", quietly = TRUE)) {
if( getFromNamespace(".jniInitialized", "rJava") == TRUE ) {
cli::cli_inform(c("!" = "You have already initialised `rJava` directly or via your Java-dependent R package in the current session. `Java` version can only be set once per session for packages that rely on `rJava`. Unless you restart the R session or run your code in a new R subprocess using `targets` or `callr`, the new `JAVA_HOME` and `PATH` will not take effect."))
if (any(installed.packages()[, 1] == "rJava")) {
if( "rJava" %in% loadedNamespaces() == TRUE ) {
cli::cli_inform(c("!" = "You have `rJava` R package loaded in the current session. If you have already initialised it directly with ``rJava::.jinit()` or via your Java-dependent R package in the current session, you may not be able to switch to a different `Java` version unless you restart R. `Java` version can only be set once per session for packages that rely on `rJava`. Unless you restart the R session or run your code in a new R subprocess using `targets` or `callr`, the new `JAVA_HOME` and `PATH` will not take effect."))
}
}

Sys.setenv(JAVA_HOME = java_home)

old_path <- Sys.getenv("PATH")
new_path <- file.path(java_home, "bin")
Sys.setenv(PATH = paste(new_path, old_path, sep = .Platform$path.sep))
Expand Down
14 changes: 14 additions & 0 deletions tools/meta-data-update-and-submission.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# before release
# usethis::use_version("patch")
cffr::cff_write()
codemetar::write_codemeta(write_minimeta = T)
usethis::use_tidy_description()
# urlchecker::url_check()
# devtools::check(remote = TRUE, manual = TRUE)
# devtools::check_win_devel()
# revdepcheck::revdep_check(num_workers = 4)

# devtools::submit_cran()

# usethis::use_github_release()
# usethis::use_dev_version(push = TRUE)

0 comments on commit 96445db

Please sign in to comment.