make java-version and distribution required for action

This commit is contained in:
Maxim Lobanov 2021-03-12 17:46:54 +03:00
parent c94ef7c5ab
commit fde2f0fa88
6 changed files with 45 additions and 68 deletions

View file

@ -41,13 +41,7 @@ export async function createAuthenticationSettings(
password: string,
gpgPassphrase: string | undefined = undefined
) {
core.info(
`Creating ${SETTINGS_FILE} with server-id: ${id};
environment variables:
username=\$${username},
password=\$${password},
and gpg-passphrase=${gpgPassphrase ? '$' + gpgPassphrase : null}`
);
core.info(`Creating ${SETTINGS_FILE} with server-id: ${id}`);
// when an alternate m2 location is specified use only that location (no .m2 directory)
// otherwise use the home/.m2/ path
const settingsDirectory: string = path.join(

View file

@ -22,7 +22,7 @@ export abstract class JavaBase {
({ version: this.version, stable: this.stable } = this.normalizeVersion(
installerOptions.version
));
this.architecture = installerOptions.arch;
this.architecture = installerOptions.architecture;
this.packageType = installerOptions.packageType;
}

View file

@ -1,6 +1,6 @@
export interface JavaInstallerOptions {
version: string;
arch: string;
architecture: string;
packageType: string;
}

View file

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