diff --git a/common.js b/common.js index 2f5c1d3ee..859b479d8 100644 --- a/common.js +++ b/common.js @@ -410,23 +410,28 @@ export async function setupJavaHome() { core.startGroup(`Modifying JAVA_HOME for JRuby`) console.log("attempting to run with existing JAVA_HOME") + let ret = await exec.exec('ruby', ['--version']); if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") } else { console.log("JRuby failed to start, try Java 21 envs") + let arch = os.arch(); - if (arch == "x64" || os.platform() != "darwin") { + if (arch === "x64" || os.platform() !== "darwin") { arch = "X64" } + let newHomeVar = `JAVA_HOME_21_${arch}`; let newHome = process.env[newHomeVar]; if (newHome === "undefined") { throw new Error(`JAVA_HOME is not Java 21+ needed for JRuby and \$${newHomeVar} is not defined`) } + console.log(`Setting JAVA_HOME to ${newHomeVar} path ${newHome}`) + core.exportVariable("JAVA_HOME", newHome) } diff --git a/dist/index.js b/dist/index.js index 963ac212d..7df843197 100644 --- a/dist/index.js +++ b/dist/index.js @@ -732,23 +732,28 @@ async function setupJavaHome() { core.startGroup(`Modifying JAVA_HOME for JRuby`) console.log("attempting to run with existing JAVA_HOME") + let ret = await _actions_exec__WEBPACK_IMPORTED_MODULE_0___default().exec('ruby', ['--version']); if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") } else { console.log("JRuby failed to start, try Java 21 envs") + let arch = os.arch(); - if (arch == "x64" || os.platform() != "darwin") { + if (arch === "x64" || os.platform() !== "darwin") { arch = "X64" } + let newHomeVar = `JAVA_HOME_21_${arch}`; let newHome = process.env[newHomeVar]; if (newHome === "undefined") { throw new Error(`JAVA_HOME is not Java 21+ needed for JRuby and \$${newHomeVar} is not defined`) } + console.log(`Setting JAVA_HOME to ${newHomeVar} path ${newHome}`) + core.exportVariable("JAVA_HOME", newHome) } @@ -74926,7 +74931,7 @@ async function setupRuby(options = {}) { const rubyPrefix = await installer.install(platform, engine, version) - if (engine == "jruby") { + if (engine === "jruby") { await common.setupJavaHome(); } diff --git a/index.js b/index.js index e47ec4693..e1b80fe91 100644 --- a/index.js +++ b/index.js @@ -79,7 +79,7 @@ export async function setupRuby(options = {}) { const rubyPrefix = await installer.install(platform, engine, version) - if (engine == "jruby") { + if (engine === "jruby") { await common.setupJavaHome(); }