Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix java_env_set_session #49

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading