@@ -7,6 +7,7 @@ const crypto = require('crypto')
77const core = require ( '@actions/core' )
88const tc = require ( '@actions/tool-cache' )
99const exec = require ( '@actions/exec' )
10+ const common = require ( './common' )
1011const { performance } = require ( 'perf_hooks' )
1112const linuxOSInfo = require ( 'linux-os-info' )
1213
@@ -406,33 +407,31 @@ export function setupPath(newPathEntries) {
406407}
407408
408409export async function setupJavaHome ( ) {
409- core . startGroup ( `Modifying JAVA_HOME for JRuby` )
410+ common . measure ( "Modifying JAVA_HOME for JRuby" , async ( ) => {
411+ console . log ( "attempting to run with existing JAVA_HOME" )
410412
411- console . log ( "attempting to run with existing JAVA_HOME" )
413+ let ret = await exec . exec ( 'ruby' , [ '--version' ] )
412414
413- let ret = await exec . exec ( 'ruby' , [ '--version' ] )
415+ if ( ret === 0 ) {
416+ console . log ( "JRuby successfully starts, using existing JAVA_HOME" )
417+ } else {
418+ console . log ( "JRuby failed to start, try Java 21 envs" )
414419
415- if ( ret === 0 ) {
416- console . log ( "JRuby successfully starts, using existing JAVA_HOME" )
417- } else {
418- console . log ( "JRuby failed to start, try Java 21 envs" )
419-
420- let arch = os . arch ( )
421- if ( arch === "x64" || os . platform ( ) !== "darwin" ) {
422- arch = "X64"
423- }
424-
425- let newHomeVar = `JAVA_HOME_21_${ arch } `
426- let newHome = process . env [ newHomeVar ]
420+ let arch = os . arch ( )
421+ if ( arch === "x64" || os . platform ( ) !== "darwin" ) {
422+ arch = "X64"
423+ }
427424
428- if ( newHome === "undefined" ) {
429- throw new Error ( `JAVA_HOME is not Java 21+ needed for JRuby and \$${ newHomeVar } is not defined` )
430- }
425+ let newHomeVar = `JAVA_HOME_21_${ arch } `
426+ let newHome = process . env [ newHomeVar ]
431427
432- console . log ( `Setting JAVA_HOME to ${ newHomeVar } path ${ newHome } ` )
428+ if ( newHome === "undefined" ) {
429+ throw new Error ( `JAVA_HOME is not Java 21+ needed for JRuby and \$${ newHomeVar } is not defined` )
430+ }
433431
434- core . exportVariable ( "JAVA_HOME" , newHome )
435- }
432+ console . log ( `Setting JAVA_HOME to ${ newHomeVar } path ${ newHome } ` )
436433
437- core . endGroup ( )
434+ core . exportVariable ( "JAVA_HOME" , newHome )
435+ }
436+ } )
438437}
0 commit comments