mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Add "Contents/Home" postfix on macOS if provider creates it (#139)
* Update e2e-versions.yml * Update e2e-versions.yml * implement fix * Update e2e-versions.yml * Update installer.ts * fix filter logic * Update e2e-versions.yml * remove extra logic * Update e2e-versions.yml
This commit is contained in:
parent
804a60faf9
commit
502a6650cd
4 changed files with 21 additions and 8 deletions
|
@ -1,10 +1,12 @@
|
|||
import * as tc from '@actions/tool-cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs';
|
||||
import semver from 'semver';
|
||||
import path from 'path';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import { getToolcachePath, getVersionFromToolcachePath, isVersionSatisfies } from '../util';
|
||||
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from './base-models';
|
||||
import { MACOS_JAVA_CONTENT_POSTFIX } from '../constants';
|
||||
|
||||
export abstract class JavaBase {
|
||||
protected http: httpm.HttpClient;
|
||||
|
@ -40,6 +42,12 @@ export abstract class JavaBase {
|
|||
core.info(`Java ${foundJava.version} was downloaded`);
|
||||
}
|
||||
|
||||
// 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 the default`);
|
||||
this.setJavaDefault(foundJava.version, foundJava.path);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue