Dont fail if jdkFile not set until checking cache

This commit is contained in:
Danny McCormick 2019-07-15 11:26:32 -04:00
parent 609f104c5b
commit 012e07621e
5 changed files with 11 additions and 3 deletions

View File

@ -11,7 +11,7 @@ inputs:
default: 'x64' default: 'x64'
jdkFile: jdkFile:
description: 'Path to where the compressed JDK is located. The path could be in your source repository or a local path on the agent.' description: 'Path to where the compressed JDK is located. The path could be in your source repository or a local path on the agent.'
required: true required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/setup-java.js' main: 'lib/setup-java.js'

View File

@ -46,6 +46,9 @@ function getJava(version, arch, jdkFile) {
core.debug(`Tool found in cache ${toolPath}`); core.debug(`Tool found in cache ${toolPath}`);
} }
else { else {
if (!jdkFile) {
throw new Error(`Failed to find Java ${version} in the cache. Please specify a valid jdk file to install from instead.`);
}
core.debug('Retrieving Jdk from local path'); core.debug('Retrieving Jdk from local path');
const compressedFileExtension = getFileEnding(jdkFile); const compressedFileExtension = getFileEnding(jdkFile);
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000)); let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));

View File

@ -23,7 +23,7 @@ function run() {
try { try {
const version = core.getInput('version', { required: true }); const version = core.getInput('version', { required: true });
const arch = core.getInput('architecture', { required: true }); const arch = core.getInput('architecture', { required: true });
const jdkFile = core.getInput('jdkFile', { required: true }); const jdkFile = core.getInput('jdkFile', { required: false }) || '';
yield installer.getJava(version, arch, jdkFile); yield installer.getJava(version, arch, jdkFile);
const matchersPath = path.join(__dirname, '..', '.github'); const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);

View File

@ -34,6 +34,11 @@ export async function getJava(
if (toolPath) { if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`); core.debug(`Tool found in cache ${toolPath}`);
} else { } else {
if (!jdkFile) {
throw new Error(
`Failed to find Java ${version} in the cache. Please specify a valid jdk file to install from instead.`
);
}
core.debug('Retrieving Jdk from local path'); core.debug('Retrieving Jdk from local path');
const compressedFileExtension = getFileEnding(jdkFile); const compressedFileExtension = getFileEnding(jdkFile);
let tempDir: string = path.join( let tempDir: string = path.join(

View File

@ -6,7 +6,7 @@ async function run() {
try { try {
const version = core.getInput('version', {required: true}); const version = core.getInput('version', {required: true});
const arch = core.getInput('architecture', {required: true}); const arch = core.getInput('architecture', {required: true});
const jdkFile = core.getInput('jdkFile', {required: true}); const jdkFile = core.getInput('jdkFile', {required: false}) || '';
await installer.getJava(version, arch, jdkFile); await installer.getJava(version, arch, jdkFile);