mirror of
https://github.com/actions/setup-java.git
synced 2025-07-01 13:24:16 +00:00
Merge branch 'main' into feature/default-to-runner-architecture
This commit is contained in:
commit
36a2b1194e
21 changed files with 4284 additions and 3630 deletions
|
@ -116,7 +116,7 @@ export async function save(id: string) {
|
|||
const packageManager = findPackageManager(id);
|
||||
const matchedKey = core.getState(CACHE_MATCHED_KEY);
|
||||
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||
|
||||
if (!primaryKey) {
|
||||
|
|
|
@ -93,7 +93,9 @@ export class AdoptDistribution extends JavaBase {
|
|||
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
|
||||
const releaseType = this.stable ? 'ga' : 'ea';
|
||||
|
||||
console.time('adopt-retrieve-available-versions');
|
||||
if (core.isDebug()) {
|
||||
console.time('adopt-retrieve-available-versions');
|
||||
}
|
||||
|
||||
const baseRequestArguments = [
|
||||
`project=jdk`,
|
||||
|
|
|
@ -143,11 +143,13 @@ export abstract class JavaBase {
|
|||
}
|
||||
|
||||
protected setJavaDefault(version: string, toolPath: string) {
|
||||
const majorVersion = version.split('.')[0];
|
||||
core.exportVariable('JAVA_HOME', toolPath);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
core.setOutput('distribution', this.distribution);
|
||||
core.setOutput('path', toolPath);
|
||||
core.setOutput('version', version);
|
||||
core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath);
|
||||
}
|
||||
|
||||
protected distributionArchitecture(): string {
|
||||
|
|
|
@ -5,7 +5,7 @@ import path from 'path';
|
|||
import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
|
||||
import { JavaBase } from '../base-installer';
|
||||
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
|
||||
import { ICorrettoAllAvailableVersions, ICorettoAvailableVersions } from './models';
|
||||
import { ICorrettoAllAvailableVersions, ICorrettoAvailableVersions } from './models';
|
||||
|
||||
export class CorrettoDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
|
@ -66,12 +66,14 @@ export class CorrettoDistribution extends JavaBase {
|
|||
return resolvedVersion;
|
||||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<ICorettoAvailableVersions[]> {
|
||||
private async getAvailableVersions(): Promise<ICorrettoAvailableVersions[]> {
|
||||
const platform = this.getPlatformOption();
|
||||
const arch = this.distributionArchitecture();
|
||||
const imageType = this.packageType;
|
||||
|
||||
console.time('coretto-retrieve-available-versions');
|
||||
if (core.isDebug()) {
|
||||
console.time('corretto-retrieve-available-versions');
|
||||
}
|
||||
|
||||
const availableVersionsUrl =
|
||||
'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';
|
||||
|
@ -83,8 +85,8 @@ export class CorrettoDistribution extends JavaBase {
|
|||
throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`);
|
||||
}
|
||||
|
||||
const eligbleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType];
|
||||
const availableVersions = this.getAvailableVersionsForPlatform(eligbleVersions);
|
||||
const eligibleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType];
|
||||
const availableVersions = this.getAvailableVersionsForPlatform(eligibleVersions);
|
||||
|
||||
if (core.isDebug()) {
|
||||
this.printAvailableVersions(availableVersions);
|
||||
|
@ -94,19 +96,19 @@ export class CorrettoDistribution extends JavaBase {
|
|||
}
|
||||
|
||||
private getAvailableVersionsForPlatform(
|
||||
eligbleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined
|
||||
): ICorettoAvailableVersions[] {
|
||||
const availableVersions: ICorettoAvailableVersions[] = [];
|
||||
eligibleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined
|
||||
): ICorrettoAvailableVersions[] {
|
||||
const availableVersions: ICorrettoAvailableVersions[] = [];
|
||||
|
||||
for (const version in eligbleVersions) {
|
||||
const availableVersion = eligbleVersions[version];
|
||||
for (const version in eligibleVersions) {
|
||||
const availableVersion = eligibleVersions[version];
|
||||
for (const fileType in availableVersion) {
|
||||
const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension();
|
||||
if (skipNonExtractableBinaries) {
|
||||
continue;
|
||||
}
|
||||
const availableVersionDetails = availableVersion[fileType];
|
||||
const correttoVersion = this.getCorettoVersion(availableVersionDetails.resource);
|
||||
const correttoVersion = this.getCorrettoVersion(availableVersionDetails.resource);
|
||||
|
||||
availableVersions.push({
|
||||
checksum: availableVersionDetails.checksum,
|
||||
|
@ -122,9 +124,9 @@ export class CorrettoDistribution extends JavaBase {
|
|||
return availableVersions;
|
||||
}
|
||||
|
||||
private printAvailableVersions(availableVersions: ICorettoAvailableVersions[]) {
|
||||
private printAvailableVersions(availableVersions: ICorrettoAvailableVersions[]) {
|
||||
core.startGroup('Print information about available versions');
|
||||
console.timeEnd('coretto-retrieve-available-versions');
|
||||
console.timeEnd('corretto-retrieve-available-versions');
|
||||
console.log(`Available versions: [${availableVersions.length}]`);
|
||||
console.log(
|
||||
availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')
|
||||
|
@ -133,7 +135,7 @@ export class CorrettoDistribution extends JavaBase {
|
|||
}
|
||||
|
||||
private getPlatformOption(): string {
|
||||
// Coretto has its own platform names so we need to map them
|
||||
// Corretto has its own platform names so we need to map them
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
|
@ -144,7 +146,7 @@ export class CorrettoDistribution extends JavaBase {
|
|||
}
|
||||
}
|
||||
|
||||
private getCorettoVersion(resource: string): string {
|
||||
private getCorrettoVersion(resource: string): string {
|
||||
const regex = /(\d+.+)\//;
|
||||
const match = regex.exec(resource);
|
||||
if (match === null) {
|
||||
|
|
|
@ -14,7 +14,7 @@ export interface ICorrettoAllAvailableVersions {
|
|||
};
|
||||
}
|
||||
|
||||
export interface ICorettoAvailableVersions {
|
||||
export interface ICorrettoAvailableVersions {
|
||||
version: string;
|
||||
fileType: string;
|
||||
checksum: string;
|
||||
|
|
|
@ -66,7 +66,9 @@ export class LibericaDistributions extends JavaBase {
|
|||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<LibericaVersion[]> {
|
||||
console.time('liberica-retrieve-available-versions');
|
||||
if (core.isDebug()) {
|
||||
console.time('liberica-retrieve-available-versions');
|
||||
}
|
||||
const url = this.prepareAvailableVersionsUrl();
|
||||
|
||||
if (core.isDebug()) {
|
||||
|
|
|
@ -91,7 +91,9 @@ export class TemurinDistribution extends JavaBase {
|
|||
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
|
||||
const releaseType = this.stable ? 'ga' : 'ea';
|
||||
|
||||
console.time('temurin-retrieve-available-versions');
|
||||
if (core.isDebug()) {
|
||||
console.time('temurin-retrieve-available-versions');
|
||||
}
|
||||
|
||||
const baseRequestArguments = [
|
||||
`project=jdk`,
|
||||
|
|
|
@ -90,7 +90,9 @@ export class ZuluDistribution extends JavaBase {
|
|||
const javafx = features?.includes('fx') ?? false;
|
||||
const releaseStatus = this.stable ? 'ga' : 'ea';
|
||||
|
||||
console.time('azul-retrieve-available-versions');
|
||||
if (core.isDebug()) {
|
||||
console.time('azul-retrieve-available-versions');
|
||||
}
|
||||
const requestArguments = [
|
||||
`os=${platform}`,
|
||||
`ext=${extension}`,
|
||||
|
|
|
@ -9,7 +9,7 @@ import { JavaInstallerOptions } from './distributions/base-models';
|
|||
|
||||
async function run() {
|
||||
try {
|
||||
const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
|
||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION, { required: true });
|
||||
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
|
||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
|
@ -17,27 +17,30 @@ async function run() {
|
|||
const cache = core.getInput(constants.INPUT_CACHE);
|
||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version,
|
||||
checkLatest
|
||||
};
|
||||
core.startGroup('Installed distributions');
|
||||
for (const version of versions) {
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version,
|
||||
checkLatest
|
||||
};
|
||||
|
||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||
if (!distribution) {
|
||||
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||
if (!distribution) {
|
||||
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
||||
}
|
||||
|
||||
const result = await distribution.setupJava();
|
||||
|
||||
core.info('');
|
||||
core.info('Java configuration:');
|
||||
core.info(` Distribution: ${distributionName}`);
|
||||
core.info(` Version: ${result.version}`);
|
||||
core.info(` Path: ${result.path}`);
|
||||
core.info('');
|
||||
}
|
||||
|
||||
const result = await distribution.setupJava();
|
||||
|
||||
core.info('');
|
||||
core.info('Java configuration:');
|
||||
core.info(` Distribution: ${distributionName}`);
|
||||
core.info(` Version: ${result.version}`);
|
||||
core.info(` Path: ${result.path}`);
|
||||
core.info('');
|
||||
|
||||
core.endGroup();
|
||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue