1
0
Fork 0
mirror of https://github.com/actions/setup-java synced 2024-11-13 00:52:39 +00:00
setup-java/src/setup-java.ts

36 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-07-10 14:54:25 +00:00
import * as core from '@actions/core';
import * as installer from './installer';
2019-11-16 00:01:13 +00:00
import * as auth from './auth';
2019-07-12 02:57:54 +00:00
import * as path from 'path';
2019-07-10 14:54:25 +00:00
async function run() {
try {
2019-08-13 20:24:39 +00:00
let version = core.getInput('version');
if (!version) {
version = core.getInput('java-version', {required: true});
}
const arch = core.getInput('architecture', {required: true});
const javaPackage = core.getInput('java-package', {required: true});
const jdkFile = core.getInput('jdkFile', {required: false}) || '';
await installer.getJava(version, arch, jdkFile, javaPackage);
2019-07-12 02:57:54 +00:00
2019-11-28 17:52:58 +00:00
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
2019-11-28 20:53:22 +00:00
const id = core.getInput('server-id', {required: false});
2019-12-19 16:52:26 +00:00
const username = core.getInput('server-username', {required: false});
const password = core.getInput('server-password', {required: false});
2019-11-16 00:01:13 +00:00
2019-11-28 20:40:08 +00:00
if (id && username && password) {
await auth.configAuthentication(id, username, password);
2019-12-19 16:52:26 +00:00
} else if (id || username || password) {
console.warn('All 3 server-(id, username, and password) are required.');
2019-11-28 17:52:58 +00:00
}
} catch (error) {
core.setFailed(error.message);
}
2019-07-10 14:54:25 +00:00
}
run();