From 0b802aad9cf5560b4ceebcf75e75bae8884ca7fc Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 16 Dec 2021 15:59:53 +0300 Subject: [PATCH 1/3] throw error for non jdk package type --- 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 fd2ca8099..d2533dabe 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(`${this.packageType} versions are not supported`); + } 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 ecce6a064..a0b7aff7a 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 477cb62e3..6b42a03f0 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(`${this.packageType} versions are not supported`); + } + const availableVersionsRaw = await this.getAvailableVersions(); const opts = this.getPlatformOption(); From af683f3474820f4fd11de7e0e8eaf05a8d739a0e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 17 Dec 2021 15:59:00 +0300 Subject: [PATCH 2/3] change error to the warning --- dist/setup/index.js | 3 ++- src/distributions/microsoft/installer.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index d2533dabe..64328d978 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -13890,7 +13890,8 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { throw new Error('Early access versions are not supported'); } if (this.packageType !== 'jdk') { - throw new Error(`${this.packageType} versions are not supported`); + this.packageType = 'jdk'; + core.warning('Microsoft Build of OpenJDK always uses the `jdk` package type. Remove the `java-package` argument when calling the action to silence this warning.'); } const availableVersionsRaw = yield this.getAvailableVersions(); const opts = this.getPlatformOption(); diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 6b42a03f0..6f20a8a34 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -46,7 +46,10 @@ export class MicrosoftDistributions extends JavaBase { } if (this.packageType !== 'jdk') { - throw new Error(`${this.packageType} versions are not supported`); + this.packageType = 'jdk'; + core.warning( + 'Microsoft Build of OpenJDK always uses the `jdk` package type. Remove the `java-package` argument when calling the action to silence this warning.' + ); } const availableVersionsRaw = await this.getAvailableVersions(); From f185ccd3ba9b270d2610d7104e978c3085a177e6 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 20 Dec 2021 18:32:00 +0300 Subject: [PATCH 3/3] change warning to error --- dist/setup/index.js | 3 +-- src/distributions/microsoft/installer.ts | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 64328d978..34b866d88 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -13890,8 +13890,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { throw new Error('Early access versions are not supported'); } if (this.packageType !== 'jdk') { - this.packageType = 'jdk'; - core.warning('Microsoft Build of OpenJDK always uses the `jdk` package type. Remove the `java-package` argument when calling the action to silence this warning.'); + throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); } const availableVersionsRaw = yield this.getAvailableVersions(); const opts = this.getPlatformOption(); diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 6f20a8a34..147c543f3 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -46,10 +46,7 @@ export class MicrosoftDistributions extends JavaBase { } if (this.packageType !== 'jdk') { - this.packageType = 'jdk'; - core.warning( - 'Microsoft Build of OpenJDK always uses the `jdk` package type. Remove the `java-package` argument when calling the action to silence this warning.' - ); + throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); } const availableVersionsRaw = await this.getAvailableVersions();