From 41f7318506ad296f5e33674cc451865ac38ab20d Mon Sep 17 00:00:00 2001 From: Marcel <34819524+MarcelCoding@users.noreply.github.com> Date: Fri, 9 Apr 2021 14:43:29 +0200 Subject: [PATCH] Fixed adopt toolchain folder --- __tests__/distributors/adopt-installer.test.ts | 18 ++++++++++++++++++ dist/setup/index.js | 4 ++-- src/distributions/adopt/installer.ts | 10 +++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/__tests__/distributors/adopt-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts index 8d224c3e..ce862c26 100644 --- a/__tests__/distributors/adopt-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -110,6 +110,24 @@ describe('getAvailableVersions', () => { expect(availableVersions).not.toBeNull(); expect(availableVersions.length).toBe(manifestData.length * 2); }); + + it.each([ + [AdoptImplementation.Hotspot, 'jdk', 'Java_Adopt_jdk'], + [AdoptImplementation.Hotspot, 'jre', 'Java_Adopt_jre'], + [AdoptImplementation.OpenJ9, 'jdk', 'Java_Adopt-OpenJ9_jdk'], + [AdoptImplementation.OpenJ9, 'jre', 'Java_Adopt-OpenJ9_jre'] + ])( + 'find right toolchain folder', + (impl: AdoptImplementation, packageType: string, expected: string) => { + const distribution = new AdoptDistribution( + { version: '11', architecture: 'x64', packageType: packageType, checkLatest: false }, + impl + ); + + // @ts-ignore - because it is protected + expect(distribution.toolcacheFolderName).toBe(expected); + } + ); }); describe('findPackageForDownload', () => { diff --git a/dist/setup/index.js b/dist/setup/index.js index 331dfdd6..d58e29d8 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -26910,7 +26910,7 @@ var AdoptImplementation; class AdoptDistribution extends base_installer_1.JavaBase { constructor(installerOptions, jvmImpl) { super(`Adopt-${jvmImpl}`, installerOptions); - this.jvmImpl = jvmImpl.toLowerCase(); + this.jvmImpl = jvmImpl; } findPackageForDownload(version) { return __awaiter(this, void 0, void 0, function* () { @@ -26981,7 +26981,7 @@ class AdoptDistribution extends base_installer_1.JavaBase { `architecture=${arch}`, `image_type=${imageType}`, `release_type=${releaseType}`, - `jvm_impl=${this.jvmImpl}` + `jvm_impl=${this.jvmImpl.toLowerCase()}` ].join('&'); // need to iterate through all pages to retrieve the list of all versions // Adopt API doesn't provide way to retrieve the count of pages to iterate so infinity loop diff --git a/src/distributions/adopt/installer.ts b/src/distributions/adopt/installer.ts index 6b604f07..97a2d329 100644 --- a/src/distributions/adopt/installer.ts +++ b/src/distributions/adopt/installer.ts @@ -16,11 +16,11 @@ export enum AdoptImplementation { } export class AdoptDistribution extends JavaBase { - private jvmImpl: string; - - constructor(installerOptions: JavaInstallerOptions, jvmImpl: AdoptImplementation) { + constructor( + installerOptions: JavaInstallerOptions, + private readonly jvmImpl: AdoptImplementation + ) { super(`Adopt-${jvmImpl}`, installerOptions); - this.jvmImpl = jvmImpl.toLowerCase(); } protected async findPackageForDownload(version: string): Promise { @@ -105,7 +105,7 @@ export class AdoptDistribution extends JavaBase { `architecture=${arch}`, `image_type=${imageType}`, `release_type=${releaseType}`, - `jvm_impl=${this.jvmImpl}` + `jvm_impl=${this.jvmImpl.toLowerCase()}` ].join('&'); // need to iterate through all pages to retrieve the list of all versions