Skip to content

Commit

Permalink
Dont fail if jdkFile not set until checking cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny McCormick committed Jul 15, 2019
1 parent 609f104 commit 012e076
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
default: 'x64'
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.'
required: true
required: false
runs:
using: 'node12'
main: 'lib/setup-java.js'
3 changes: 3 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function getJava(version, arch, jdkFile) {
core.debug(`Tool found in cache ${toolPath}`);
}
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');
const compressedFileExtension = getFileEnding(jdkFile);
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));
Expand Down
2 changes: 1 addition & 1 deletion lib/setup-java.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function run() {
try {
const version = core.getInput('version', { 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);
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
Expand Down
5 changes: 5 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export async function getJava(
if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`);
} 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');
const compressedFileExtension = getFileEnding(jdkFile);
let tempDir: string = path.join(
Expand Down
2 changes: 1 addition & 1 deletion src/setup-java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function run() {
try {
const version = core.getInput('version', {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);

Expand Down

0 comments on commit 012e076

Please sign in to comment.