setup-java/src/setup-java.ts
Janne Valkealahti 7b8939ae83 Add support for maven/gradle versions
- Essentially use same concepts as jdk install to switch
  maven and gradle versions if those are defined with config.
- Bump to tool-cache 1.3.0 as 1.0.0 tries to use
  node_modules/@actions/tool-cache/scripts/externals/unzip which doesn't have
  execute flag so you'd get `Permission denied`
- `extractZipNix` in toolkit no longer support relative path so needs to
  resolve absolute path before passing file to these methods.
- Commit has my local build for `index.js` which probably should get
  recreated but makes it easier to test this from a PR branch.
- Fixes #40
2020-01-17 12:58:57 +00:00

48 lines
1.8 KiB
TypeScript

import * as core from '@actions/core';
import * as installer from './installer';
import * as mavenInstaller from './maven-installer';
import * as gradleInstaller from './gradle-installer';
import * as auth from './auth';
import * as path from 'path';
async function run() {
try {
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);
const mavenVersion = core.getInput('maven-version', {required: false});
const mavenFile = core.getInput('maven-file', {required: false}) || '';
const mavenMirror = core.getInput('maven-mirror', {required: false});
if (mavenVersion) {
await mavenInstaller.getMaven(mavenVersion, mavenFile, mavenMirror);
}
const gradleVersion = core.getInput('gradle-version', {required: false});
const gradleFile = core.getInput('gradle-file', {required: false}) || '';
if (gradleVersion) {
await gradleInstaller.getGradle(gradleVersion, gradleFile);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
const id = core.getInput('server-id', {required: false}) || undefined;
const username =
core.getInput('server-username', {required: false}) || undefined;
const password =
core.getInput('server-password', {required: false}) || undefined;
await auth.configAuthentication(id, username, password);
} catch (error) {
core.setFailed(error.message);
}
}
run();