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

@ -5,10 +5,10 @@ author: 'GitHub'
inputs: inputs:
java-version: java-version:
description: 'The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file' description: 'The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file'
required: false required: true
distribution: distribution:
description: 'Java distribution. See the list of supported distributions in README file' description: 'Java distribution. See the list of supported distributions in README file'
required: false required: true
java-package: java-package:
description: 'The package type (jdk, jre, jdk+fx, jre+fx)' description: 'The package type (jdk, jre, jdk+fx, jre+fx)'
required: false required: false

49
dist/setup/index.js vendored
View file

@ -3963,7 +3963,7 @@ class JavaBase {
maxRetries: 3 maxRetries: 3
}); });
({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version));
this.architecture = installerOptions.arch; this.architecture = installerOptions.architecture;
this.packageType = installerOptions.packageType; this.packageType = installerOptions.packageType;
} }
setupJava() { setupJava() {
@ -13281,11 +13281,7 @@ function configureAuthentication() {
exports.configureAuthentication = configureAuthentication; exports.configureAuthentication = configureAuthentication;
function createAuthenticationSettings(id, username, password, gpgPassphrase = undefined) { function createAuthenticationSettings(id, username, password, gpgPassphrase = undefined) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}; core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}`);
environment variables:
username=\$${username},
password=\$${password},
and gpg-passphrase=${gpgPassphrase ? '$' + gpgPassphrase : null}`);
// when an alternate m2 location is specified use only that location (no .m2 directory) // when an alternate m2 location is specified use only that location (no .m2 directory)
// otherwise use the home/.m2/ path // otherwise use the home/.m2/ path
const settingsDirectory = path.join(core.getInput(constants.INPUT_SETTINGS_PATH) || os.homedir(), core.getInput(constants.INPUT_SETTINGS_PATH) ? '' : exports.M2_DIR); const settingsDirectory = path.join(core.getInput(constants.INPUT_SETTINGS_PATH) || os.homedir(), core.getInput(constants.INPUT_SETTINGS_PATH) ? '' : exports.M2_DIR);
@ -35640,32 +35636,27 @@ const distribution_factory_1 = __webpack_require__(24);
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const version = core.getInput(constants.INPUT_JAVA_VERSION); const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
const arch = core.getInput(constants.INPUT_ARCHITECTURE); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION); const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
const jdkFile = core.getInput(constants.INPUT_JDK_FILE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
if (version || distributionName) { const installerOptions = {
if (!version || !distributionName) { architecture,
throw new Error(`Both ${constants.INPUT_JAVA_VERSION} and ${constants.INPUT_DISTRIBUTION} inputs are required if one of them is specified`); packageType,
} version
const installerOptions = { };
arch, const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
packageType, if (!distribution) {
version throw new Error(`No supported distribution was found for input ${distributionName}`);
};
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
if (!distribution) {
throw new Error(`No supported distribution was found for input ${distributionName}`);
}
const result = yield 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 = yield 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'); const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
yield auth.configureAuthentication(); yield auth.configureAuthentication();

View file

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

View file

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

View file

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

View file

@ -8,40 +8,32 @@ import { JavaInstallerOptions } from './distributions/base-models';
async function run() { async function run() {
try { try {
const version = core.getInput(constants.INPUT_JAVA_VERSION); const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
const arch = core.getInput(constants.INPUT_ARCHITECTURE); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION); const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
const jdkFile = core.getInput(constants.INPUT_JDK_FILE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
if (version || distributionName) { const installerOptions: JavaInstallerOptions = {
if (!version || !distributionName) { architecture,
throw new Error( packageType,
`Both ${constants.INPUT_JAVA_VERSION} and ${constants.INPUT_DISTRIBUTION} inputs are required if one of them is specified` version
); };
}
const installerOptions: JavaInstallerOptions = { const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
arch, if (!distribution) {
packageType, throw new Error(`No supported distribution was found for input ${distributionName}`);
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 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'); const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);