diff --git a/dist/setup/index.js b/dist/setup/index.js index 2820ec37..cbbe5142 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -104417,16 +104417,16 @@ class LocalDistribution extends base_installer_1.JavaBase { const archivePath = path_1.default.join(extractedJavaPath, archiveName); const javaVersion = this.version; let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture); - // for different Java distributions, postfix can exist or not so need to check both cases - if (process.platform === 'darwin' && - fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) { - javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX); - } foundJava = { version: javaVersion, path: javaPath }; } + // JDK folder may contain postfix "Contents/Home" on macOS + const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX); + if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) { + foundJava.path = macOSPostfixPath; + } core.info(`Setting Java ${foundJava.version} as default`); this.setJavaDefault(foundJava.version, foundJava.path); return foundJava; diff --git a/src/distributions/local/installer.ts b/src/distributions/local/installer.ts index 1402bc85..0b91febf 100644 --- a/src/distributions/local/installer.ts +++ b/src/distributions/local/installer.ts @@ -46,20 +46,18 @@ export class LocalDistribution extends JavaBase { this.architecture ); - // for different Java distributions, postfix can exist or not so need to check both cases - if ( - process.platform === 'darwin' && - fs.existsSync(path.join(javaPath, MACOS_JAVA_CONTENT_POSTFIX)) - ) { - javaPath = path.join(javaPath, MACOS_JAVA_CONTENT_POSTFIX); - } - foundJava = { version: javaVersion, path: javaPath }; } + // JDK folder may contain postfix "Contents/Home" on macOS + const macOSPostfixPath = path.join(foundJava.path, MACOS_JAVA_CONTENT_POSTFIX); + if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) { + foundJava.path = macOSPostfixPath; + } + core.info(`Setting Java ${foundJava.version} as default`); this.setJavaDefault(foundJava.version, foundJava.path);