mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c79f721fa | ||
|
|
e17c5ea7eb | ||
|
|
f0a4d6bddd |
@@ -6,6 +6,7 @@ const stream = require('stream')
|
|||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const tc = require('@actions/tool-cache')
|
const tc = require('@actions/tool-cache')
|
||||||
|
const exec = require('@actions/exec')
|
||||||
const { performance } = require('perf_hooks')
|
const { performance } = require('perf_hooks')
|
||||||
const linuxOSInfo = require('linux-os-info')
|
const linuxOSInfo = require('linux-os-info')
|
||||||
|
|
||||||
@@ -403,3 +404,33 @@ export function setupPath(newPathEntries) {
|
|||||||
core.addPath(newPath.join(path.delimiter))
|
core.addPath(newPath.join(path.delimiter))
|
||||||
return msys2Type
|
return msys2Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setupJavaHome(rubyPrefix) {
|
||||||
|
await measure("Modifying JAVA_HOME for JRuby", async () => {
|
||||||
|
console.log("attempting to run with existing JAVA_HOME")
|
||||||
|
|
||||||
|
let ret = await exec.exec('java', ['-jar', path.join(rubyPrefix, 'lib/jruby.jar'), '--version'], {ignoreReturnCode: true})
|
||||||
|
|
||||||
|
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") {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
+38
-1
@@ -315,7 +315,8 @@ __nccwpck_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ "toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile),
|
/* harmony export */ "toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile),
|
||||||
/* harmony export */ "createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile),
|
/* harmony export */ "createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile),
|
||||||
/* harmony export */ "win2nix": () => (/* binding */ win2nix),
|
/* harmony export */ "win2nix": () => (/* binding */ win2nix),
|
||||||
/* harmony export */ "setupPath": () => (/* binding */ setupPath)
|
/* harmony export */ "setupPath": () => (/* binding */ setupPath),
|
||||||
|
/* harmony export */ "setupJavaHome": () => (/* binding */ setupJavaHome)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
const os = __nccwpck_require__(2037)
|
const os = __nccwpck_require__(2037)
|
||||||
const path = __nccwpck_require__(1017)
|
const path = __nccwpck_require__(1017)
|
||||||
@@ -325,6 +326,7 @@ const stream = __nccwpck_require__(2781)
|
|||||||
const crypto = __nccwpck_require__(6113)
|
const crypto = __nccwpck_require__(6113)
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const tc = __nccwpck_require__(7784)
|
const tc = __nccwpck_require__(7784)
|
||||||
|
const exec = __nccwpck_require__(1514)
|
||||||
const { performance } = __nccwpck_require__(4074)
|
const { performance } = __nccwpck_require__(4074)
|
||||||
const linuxOSInfo = __nccwpck_require__(8487)
|
const linuxOSInfo = __nccwpck_require__(8487)
|
||||||
|
|
||||||
@@ -723,6 +725,36 @@ function setupPath(newPathEntries) {
|
|||||||
return msys2Type
|
return msys2Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setupJavaHome(rubyPrefix) {
|
||||||
|
await measure("Modifying JAVA_HOME for JRuby", async () => {
|
||||||
|
console.log("attempting to run with existing JAVA_HOME")
|
||||||
|
|
||||||
|
let ret = await exec.exec('java', ['-jar', path.join(rubyPrefix, 'lib/jruby.jar'), '--version'], {ignoreReturnCode: true})
|
||||||
|
|
||||||
|
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") {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@@ -74057,6 +74089,11 @@ async function install(platform, engine, version) {
|
|||||||
await downloadAndExtract(platform, engine, version, rubyPrefix)
|
await downloadAndExtract(platform, engine, version, rubyPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure JRuby has minimum Java version to run
|
||||||
|
if (engine === "jruby") {
|
||||||
|
await common.setupJavaHome(rubyPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
return rubyPrefix
|
return rubyPrefix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ export async function install(platform, engine, version) {
|
|||||||
await downloadAndExtract(platform, engine, version, rubyPrefix)
|
await downloadAndExtract(platform, engine, version, rubyPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure JRuby has minimum Java version to run
|
||||||
|
if (engine === "jruby") {
|
||||||
|
await common.setupJavaHome(rubyPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
return rubyPrefix
|
return rubyPrefix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user