From f0bb91606209742fe3ea40199be2f3ef195ecabf Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 21 Dec 2021 13:29:16 +0300 Subject: [PATCH] Add an error condition for non jdk Microsoft OpenJDK build (#265) --- dist/setup/index.js | 3 +++ docs/advanced-usage.md | 11 +++++++++++ src/distributions/microsoft/installer.ts | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index fd2ca80..34b866d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -13889,6 +13889,9 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { if (!this.stable) { throw new Error('Early access versions are not supported'); } + if (this.packageType !== 'jdk') { + throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); + } const availableVersionsRaw = yield this.getAvailableVersions(); const opts = this.getPlatformOption(); const availableVersions = availableVersionsRaw.map(item => ({ diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index ecce6a0..a0b7aff 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -65,6 +65,17 @@ steps: - run: java -cp java HelloWorldApp ``` +### Microsoft +```yaml +steps: +- uses: actions/checkout@v2 +- uses: actions/setup-java@v2 + with: + distribution: 'microsoft' + java-version: '11' +- run: java -cp java HelloWorldApp +``` + ## Installing custom Java package type ```yaml steps: diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 477cb62..147c543 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -45,6 +45,10 @@ export class MicrosoftDistributions extends JavaBase { throw new Error('Early access versions are not supported'); } + if (this.packageType !== 'jdk') { + throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); + } + const availableVersionsRaw = await this.getAvailableVersions(); const opts = this.getPlatformOption();