2019-07-10 10:54:25 -04:00
|
|
|
import * as core from '@actions/core';
|
2019-11-15 19:01:13 -05:00
|
|
|
import * as auth from './auth';
|
2022-03-31 15:09:57 -04:00
|
|
|
import { getBooleanInput, isCacheFeatureAvailable } from './util';
|
2020-07-15 21:53:39 -04:00
|
|
|
import * as constants from './constants';
|
2021-08-19 13:19:35 -04:00
|
|
|
import { restore } from './cache';
|
2019-07-11 22:57:54 -04:00
|
|
|
import * as path from 'path';
|
2021-04-05 06:02:27 -04:00
|
|
|
import { getJavaDistribution } from './distributions/distribution-factory';
|
|
|
|
import { JavaInstallerOptions } from './distributions/base-models';
|
2019-07-10 10:54:25 -04:00
|
|
|
|
|
|
|
async function run() {
|
2019-07-10 23:11:48 -04:00
|
|
|
try {
|
2021-04-05 06:02:27 -04:00
|
|
|
const version = core.getInput(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);
|
|
|
|
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
2021-08-19 13:19:35 -04:00
|
|
|
const cache = core.getInput(constants.INPUT_CACHE);
|
2021-04-05 06:02:27 -04:00
|
|
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
|
|
|
|
|
|
|
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}`);
|
2019-08-13 16:24:39 -04:00
|
|
|
}
|
2020-08-24 06:35:41 -04:00
|
|
|
|
2021-04-05 06:02:27 -04:00
|
|
|
const result = await distribution.setupJava();
|
2019-07-10 23:11:48 -04:00
|
|
|
|
2021-04-05 06:02:27 -04:00
|
|
|
core.info('');
|
|
|
|
core.info('Java configuration:');
|
|
|
|
core.info(` Distribution: ${distributionName}`);
|
|
|
|
core.info(` Version: ${result.version}`);
|
|
|
|
core.info(` Path: ${result.path}`);
|
|
|
|
core.info('');
|
2019-07-11 22:57:54 -04:00
|
|
|
|
2020-05-02 07:33:15 -04:00
|
|
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
2020-07-15 21:53:39 -04:00
|
|
|
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
|
|
|
|
2021-04-05 06:02:27 -04:00
|
|
|
await auth.configureAuthentication();
|
2022-03-31 15:09:57 -04:00
|
|
|
if (cache && isCacheFeatureAvailable()) {
|
2021-08-19 13:19:35 -04:00
|
|
|
await restore(cache);
|
|
|
|
}
|
2019-07-10 23:11:48 -04:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
2019-07-10 10:54:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
run();
|