Skip to content

Commit 012e076

Browse files
author
Danny McCormick
committed
Dont fail if jdkFile not set until checking cache
1 parent 609f104 commit 012e076

5 files changed

Lines changed: 11 additions & 3 deletions

File tree

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
default: 'x64'
1212
jdkFile:
1313
description: 'Path to where the compressed JDK is located. The path could be in your source repository or a local path on the agent.'
14-
required: true
14+
required: false
1515
runs:
1616
using: 'node12'
1717
main: 'lib/setup-java.js'

lib/installer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function getJava(version, arch, jdkFile) {
4646
core.debug(`Tool found in cache ${toolPath}`);
4747
}
4848
else {
49+
if (!jdkFile) {
50+
throw new Error(`Failed to find Java ${version} in the cache. Please specify a valid jdk file to install from instead.`);
51+
}
4952
core.debug('Retrieving Jdk from local path');
5053
const compressedFileExtension = getFileEnding(jdkFile);
5154
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));

lib/setup-java.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function run() {
2323
try {
2424
const version = core.getInput('version', { required: true });
2525
const arch = core.getInput('architecture', { required: true });
26-
const jdkFile = core.getInput('jdkFile', { required: true });
26+
const jdkFile = core.getInput('jdkFile', { required: false }) || '';
2727
yield installer.getJava(version, arch, jdkFile);
2828
const matchersPath = path.join(__dirname, '..', '.github');
2929
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);

src/installer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export async function getJava(
3434
if (toolPath) {
3535
core.debug(`Tool found in cache ${toolPath}`);
3636
} else {
37+
if (!jdkFile) {
38+
throw new Error(
39+
`Failed to find Java ${version} in the cache. Please specify a valid jdk file to install from instead.`
40+
);
41+
}
3742
core.debug('Retrieving Jdk from local path');
3843
const compressedFileExtension = getFileEnding(jdkFile);
3944
let tempDir: string = path.join(

src/setup-java.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function run() {
66
try {
77
const version = core.getInput('version', {required: true});
88
const arch = core.getInput('architecture', {required: true});
9-
const jdkFile = core.getInput('jdkFile', {required: true});
9+
const jdkFile = core.getInput('jdkFile', {required: false}) || '';
1010

1111
await installer.getJava(version, arch, jdkFile);
1212

0 commit comments

Comments
 (0)