Skip to content

Commit

Permalink
Cleanup based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 11, 2025
1 parent 2502fcd commit 29d6dd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 7 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 29d6dd3

Please # to comment.