Add support for multiple jdks (#368)

This commit is contained in:
Dmitry Shibanov
2022-09-08 15:26:54 +02:00
committed by GitHub
parent 749e4491fa
commit d854b6da19
15 changed files with 4219 additions and 3569 deletions

View File

@ -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`,

View File

@ -142,10 +142,12 @@ export abstract class JavaBase {
}
protected setJavaDefault(version: string, toolPath: string) {
const majorVerssion = 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_${majorVerssion}_${this.architecture.toUpperCase()}`, toolPath);
}
}

View File

@ -71,7 +71,9 @@ export class CorrettoDistribution extends JavaBase {
const arch = this.architecture;
const imageType = this.packageType;
console.time('coretto-retrieve-available-versions');
if (core.isDebug()) {
console.time('coretto-retrieve-available-versions');
}
const availableVersionsUrl =
'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';

View File

@ -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()) {

View File

@ -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`,

View File

@ -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}`,

View File

@ -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')}`);