diff --git a/setup-r-dependencies/README.md b/setup-r-dependencies/README.md index 8705132c..e361a3c4 100644 --- a/setup-r-dependencies/README.md +++ b/setup-r-dependencies/README.md @@ -301,6 +301,10 @@ On Windows you can usually use `pacman` that is included in Rtools4, or choco install mariadb ``` +`setup-r-dependencies` also sets `JAVA_HOME` to Java 21 on GitHub-hosted +Windows runners (`JAVA_HOME_21_X64` on x64, `JAVA_HOME_21_AARCH64` on arm64) +if `JAVA_HOME` is not already set. + # Installing the latest dependencies Note that `setup-r-dependencies` does _not_ necessarily install the latest diff --git a/setup-r-dependencies/action.yaml b/setup-r-dependencies/action.yaml index e7082ba1..bb19e3ef 100644 --- a/setup-r-dependencies/action.yaml +++ b/setup-r-dependencies/action.yaml @@ -128,6 +128,20 @@ runs: cat("::endgroup::\n") shell: Rscript {0} + - name: Set JAVA_HOME (Windows) + if: ${{ runner.os == 'Windows' }} + shell: bash + run: | + if [ -z "${JAVA_HOME:-}" ]; then + arch="${RUNNER_ARCH^^}" + case "${arch}" in + X64) echo "JAVA_HOME=${JAVA_HOME_21_X64}" >> $GITHUB_ENV ;; + # GitHub runners expose ARM64 Java 21 in JAVA_HOME_21_AARCH64. + ARM64) echo "JAVA_HOME=${JAVA_HOME_21_AARCH64}" >> $GITHUB_ENV ;; + *) echo "Warning: unsupported Windows architecture '${arch}', JAVA_HOME not set by setup-r-dependencies." >&2 ;; + esac + fi + - name: Install pak (Unix) if: ${{ runner.os != 'Windows' && inputs.pak-version != 'none' }} run: |