mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 18:36:46 +00:00
implement fix
This commit is contained in:
parent
2af39a78a7
commit
b082205a41
4 changed files with 44 additions and 10 deletions
|
@ -67,10 +67,6 @@ export class AdoptDistribution extends JavaBase {
|
|||
|
||||
javaPath = await tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
javaPath = path.join(javaPath, MACOS_JAVA_CONTENT_POSTFIX);
|
||||
}
|
||||
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -72,8 +72,10 @@ export class ZuluDistribution extends JavaBase {
|
|||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||
|
||||
const jdkPath = this.findJDKInstallationSubfolder(archivePath);
|
||||
|
||||
const javaPath = await tc.cacheDir(
|
||||
archivePath,
|
||||
jdkPath,
|
||||
this.toolcacheFolderName,
|
||||
this.getToolcacheVersionName(javaRelease.version),
|
||||
this.architecture
|
||||
|
@ -160,4 +162,17 @@ export class ZuluDistribution extends JavaBase {
|
|||
|
||||
return mainVersion;
|
||||
}
|
||||
|
||||
private findJDKInstallationSubfolder(archiveFolder: string) {
|
||||
// Zulu archive contains a bunch of symlinks and zulu-<major_version>.jdk subfolder
|
||||
const jdkFolders = fs
|
||||
.readdirSync(archiveFolder, { withFileTypes: true })
|
||||
.filter(item => !item.isSymbolicLink())
|
||||
.filter(item => item.name.startsWith('zulu-') && item.name.endsWith('.jdk'));
|
||||
if (jdkFolders.length === 0) {
|
||||
return archiveFolder;
|
||||
}
|
||||
|
||||
return path.join(archiveFolder, jdkFolders[0].name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue