mirror of
https://github.com/actions/setup-java.git
synced 2025-06-29 20:44:14 +00:00
make java-version and distribution required for action
This commit is contained in:
parent
c94ef7c5ab
commit
fde2f0fa88
6 changed files with 45 additions and 68 deletions
|
@ -8,40 +8,32 @@ import { JavaInstallerOptions } from './distributions/base-models';
|
|||
|
||||
async function run() {
|
||||
try {
|
||||
const version = core.getInput(constants.INPUT_JAVA_VERSION);
|
||||
const arch = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION);
|
||||
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);
|
||||
|
||||
if (version || distributionName) {
|
||||
if (!version || !distributionName) {
|
||||
throw new Error(
|
||||
`Both ‘${constants.INPUT_JAVA_VERSION}’ and ‘${constants.INPUT_DISTRIBUTION}’ inputs are required if one of them is specified`
|
||||
);
|
||||
}
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version
|
||||
};
|
||||
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
arch,
|
||||
packageType,
|
||||
version
|
||||
};
|
||||
|
||||
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 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 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