Added 'adopt-hotspot' and 'adopt-openj9' (#155)
* Added 'adopt-hotspot' and 'adopt-openj9' * Fixed adopt toolchain folder
This commit is contained in:
		
							parent
							
								
									0443912ed7
								
							
						
					
					
						commit
						cbc183b1c1
					
				
							
								
								
									
										2
									
								
								.github/workflows/e2e-versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/e2e-versions.yml
									
									
									
									
										vendored
									
									
								
							| @ -19,7 +19,7 @@ jobs: | |||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [macos-latest, windows-latest, ubuntu-latest] |         os: [macos-latest, windows-latest, ubuntu-latest] | ||||||
|         distribution: ['adopt', 'zulu'] |         distribution: ['adopt', 'adopt-openj9', 'zulu'] # internally 'adopt-hotspot' is the same as 'adopt' | ||||||
|         version: ['8', '11', '15'] |         version: ['8', '11', '15'] | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout |       - name: Checkout | ||||||
|  | |||||||
| @ -53,7 +53,8 @@ Currently, the following distributions are supported: | |||||||
| | Keyword | Distribution | Official site | License | | | Keyword | Distribution | Official site | License | | ||||||
| |-|-|-|-| | |-|-|-|-| | ||||||
| | `zulu` | Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) | | | `zulu` | Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) | | ||||||
| | `adopt` | Adopt OpenJDK | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | | `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | ||||||
|  | | `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | ||||||
| 
 | 
 | ||||||
| **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. | **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,8 +1,6 @@ | |||||||
| import { HttpClient } from '@actions/http-client'; | import { HttpClient } from '@actions/http-client'; | ||||||
| 
 | 
 | ||||||
| import * as semver from 'semver'; | import { AdoptDistribution, AdoptImplementation } from '../../src/distributions/adopt/installer'; | ||||||
| 
 |  | ||||||
| import { AdoptDistribution } from '../../src/distributions/adopt/installer'; |  | ||||||
| import { JavaInstallerOptions } from '../../src/distributions/base-models'; | import { JavaInstallerOptions } from '../../src/distributions/base-models'; | ||||||
| 
 | 
 | ||||||
| let manifestData = require('../data/adopt.json') as []; | let manifestData = require('../data/adopt.json') as []; | ||||||
| @ -28,26 +26,54 @@ describe('getAvailableVersions', () => { | |||||||
|   it.each([ |   it.each([ | ||||||
|     [ |     [ | ||||||
|       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0' |       AdoptImplementation.Hotspot, | ||||||
|  |       'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0' | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, |       { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, | ||||||
|       'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0' |       AdoptImplementation.Hotspot, | ||||||
|  |       'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0' | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       { version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, |       { version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, | ||||||
|       'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0' |       AdoptImplementation.Hotspot, | ||||||
|  |       'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=hotspot&page_size=20&page=0' | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       { version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false }, |       { version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0' |       AdoptImplementation.Hotspot, | ||||||
|  |       'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=hotspot&page_size=20&page=0' | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|  |       AdoptImplementation.OpenJ9, | ||||||
|  |       'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0' | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, | ||||||
|  |       AdoptImplementation.OpenJ9, | ||||||
|  |       'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0' | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       { version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, | ||||||
|  |       AdoptImplementation.OpenJ9, | ||||||
|  |       'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0' | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       { version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|  |       AdoptImplementation.OpenJ9, | ||||||
|  |       'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=openj9&page_size=20&page=0' | ||||||
|     ] |     ] | ||||||
|   ])( |   ])( | ||||||
|     'build correct url for %s', |     'build correct url for %s', | ||||||
|     async (installerOptions: JavaInstallerOptions, expectedParameters) => { |     async ( | ||||||
|       const distribution = new AdoptDistribution(installerOptions); |       installerOptions: JavaInstallerOptions, | ||||||
|  |       impl: AdoptImplementation, | ||||||
|  |       expectedParameters | ||||||
|  |     ) => { | ||||||
|  |       const distribution = new AdoptDistribution(installerOptions, impl); | ||||||
|       const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D'; |       const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D'; | ||||||
|       const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&jvm_impl=hotspot&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`; |       const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`; | ||||||
|       distribution['getPlatformOption'] = () => 'mac'; |       distribution['getPlatformOption'] = () => 'mac'; | ||||||
| 
 | 
 | ||||||
|       await distribution['getAvailableVersions'](); |       await distribution['getAvailableVersions'](); | ||||||
| @ -76,16 +102,32 @@ describe('getAvailableVersions', () => { | |||||||
|         result: [] |         result: [] | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|     const distribution = new AdoptDistribution({ |     const distribution = new AdoptDistribution( | ||||||
|       version: '11', |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       architecture: 'x64', |       AdoptImplementation.Hotspot | ||||||
|       packageType: 'jdk', |     ); | ||||||
|       checkLatest: false |  | ||||||
|     }); |  | ||||||
|     const availableVersions = await distribution['getAvailableVersions'](); |     const availableVersions = await distribution['getAvailableVersions'](); | ||||||
|     expect(availableVersions).not.toBeNull(); |     expect(availableVersions).not.toBeNull(); | ||||||
|     expect(availableVersions.length).toBe(manifestData.length * 2); |     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', () => { | describe('findPackageForDownload', () => { | ||||||
| @ -102,24 +144,20 @@ describe('findPackageForDownload', () => { | |||||||
|     ['15.0.1+9', '15.0.1+9'], |     ['15.0.1+9', '15.0.1+9'], | ||||||
|     ['15.0.1+9.1', '15.0.1+9.1'] |     ['15.0.1+9.1', '15.0.1+9.1'] | ||||||
|   ])('version is resolved correctly %s -> %s', async (input, expected) => { |   ])('version is resolved correctly %s -> %s', async (input, expected) => { | ||||||
|     const distribution = new AdoptDistribution({ |     const distribution = new AdoptDistribution( | ||||||
|       version: '11', |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       architecture: 'x64', |       AdoptImplementation.Hotspot | ||||||
|       packageType: 'jdk', |     ); | ||||||
|       checkLatest: false |  | ||||||
|     }); |  | ||||||
|     distribution['getAvailableVersions'] = async () => manifestData; |     distribution['getAvailableVersions'] = async () => manifestData; | ||||||
|     const resolvedVersion = await distribution['findPackageForDownload'](input); |     const resolvedVersion = await distribution['findPackageForDownload'](input); | ||||||
|     expect(resolvedVersion.version).toBe(expected); |     expect(resolvedVersion.version).toBe(expected); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('version is found but binaries list is empty', async () => { |   it('version is found but binaries list is empty', async () => { | ||||||
|     const distribution = new AdoptDistribution({ |     const distribution = new AdoptDistribution( | ||||||
|       version: '11', |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       architecture: 'x64', |       AdoptImplementation.Hotspot | ||||||
|       packageType: 'jdk', |     ); | ||||||
|       checkLatest: false |  | ||||||
|     }); |  | ||||||
|     distribution['getAvailableVersions'] = async () => manifestData; |     distribution['getAvailableVersions'] = async () => manifestData; | ||||||
|     await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError( |     await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError( | ||||||
|       /Could not find satisfied version for SemVer */ |       /Could not find satisfied version for SemVer */ | ||||||
| @ -127,12 +165,10 @@ describe('findPackageForDownload', () => { | |||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('version is not found', async () => { |   it('version is not found', async () => { | ||||||
|     const distribution = new AdoptDistribution({ |     const distribution = new AdoptDistribution( | ||||||
|       version: '11', |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       architecture: 'x64', |       AdoptImplementation.Hotspot | ||||||
|       packageType: 'jdk', |     ); | ||||||
|       checkLatest: false |  | ||||||
|     }); |  | ||||||
|     distribution['getAvailableVersions'] = async () => manifestData; |     distribution['getAvailableVersions'] = async () => manifestData; | ||||||
|     await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError( |     await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError( | ||||||
|       /Could not find satisfied version for SemVer */ |       /Could not find satisfied version for SemVer */ | ||||||
| @ -140,12 +176,10 @@ describe('findPackageForDownload', () => { | |||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('version list is empty', async () => { |   it('version list is empty', async () => { | ||||||
|     const distribution = new AdoptDistribution({ |     const distribution = new AdoptDistribution( | ||||||
|       version: '11', |       { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, | ||||||
|       architecture: 'x64', |       AdoptImplementation.Hotspot | ||||||
|       packageType: 'jdk', |     ); | ||||||
|       checkLatest: false |  | ||||||
|     }); |  | ||||||
|     distribution['getAvailableVersions'] = async () => []; |     distribution['getAvailableVersions'] = async () => []; | ||||||
|     await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError( |     await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError( | ||||||
|       /Could not find satisfied version for SemVer */ |       /Could not find satisfied version for SemVer */ | ||||||
|  | |||||||
							
								
								
									
										41
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @ -1476,23 +1476,28 @@ exports.string = string; | |||||||
| 
 | 
 | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| exports.getJavaDistribution = void 0; | exports.getJavaDistribution = void 0; | ||||||
| const installer_1 = __webpack_require__(584); | const installer_1 = __webpack_require__(144); | ||||||
| const installer_2 = __webpack_require__(144); | const installer_2 = __webpack_require__(393); | ||||||
| const installer_3 = __webpack_require__(393); | const installer_3 = __webpack_require__(584); | ||||||
| var JavaDistribution; | var JavaDistribution; | ||||||
| (function (JavaDistribution) { | (function (JavaDistribution) { | ||||||
|     JavaDistribution["Adopt"] = "adopt"; |     JavaDistribution["Adopt"] = "adopt"; | ||||||
|  |     JavaDistribution["AdoptHotspot"] = "adopt-hotspot"; | ||||||
|  |     JavaDistribution["AdoptOpenJ9"] = "adopt-openj9"; | ||||||
|     JavaDistribution["Zulu"] = "zulu"; |     JavaDistribution["Zulu"] = "zulu"; | ||||||
|     JavaDistribution["JdkFile"] = "jdkfile"; |     JavaDistribution["JdkFile"] = "jdkfile"; | ||||||
| })(JavaDistribution || (JavaDistribution = {})); | })(JavaDistribution || (JavaDistribution = {})); | ||||||
| function getJavaDistribution(distributionName, installerOptions, jdkFile) { | function getJavaDistribution(distributionName, installerOptions, jdkFile) { | ||||||
|     switch (distributionName) { |     switch (distributionName) { | ||||||
|         case JavaDistribution.JdkFile: |         case JavaDistribution.JdkFile: | ||||||
|             return new installer_2.LocalDistribution(installerOptions, jdkFile); |             return new installer_1.LocalDistribution(installerOptions, jdkFile); | ||||||
|         case JavaDistribution.Adopt: |         case JavaDistribution.Adopt: | ||||||
|             return new installer_1.AdoptDistribution(installerOptions); |         case JavaDistribution.AdoptHotspot: | ||||||
|  |             return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.Hotspot); | ||||||
|  |         case JavaDistribution.AdoptOpenJ9: | ||||||
|  |             return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.OpenJ9); | ||||||
|         case JavaDistribution.Zulu: |         case JavaDistribution.Zulu: | ||||||
|             return new installer_3.ZuluDistribution(installerOptions); |             return new installer_2.ZuluDistribution(installerOptions); | ||||||
|         default: |         default: | ||||||
|             return null; |             return null; | ||||||
|     } |     } | ||||||
| @ -26889,7 +26894,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| exports.AdoptDistribution = void 0; | exports.AdoptDistribution = exports.AdoptImplementation = void 0; | ||||||
| const core = __importStar(__webpack_require__(470)); | const core = __importStar(__webpack_require__(470)); | ||||||
| const tc = __importStar(__webpack_require__(139)); | const tc = __importStar(__webpack_require__(139)); | ||||||
| const fs_1 = __importDefault(__webpack_require__(747)); | const fs_1 = __importDefault(__webpack_require__(747)); | ||||||
| @ -26897,9 +26902,15 @@ const path_1 = __importDefault(__webpack_require__(622)); | |||||||
| const semver_1 = __importDefault(__webpack_require__(876)); | const semver_1 = __importDefault(__webpack_require__(876)); | ||||||
| const base_installer_1 = __webpack_require__(83); | const base_installer_1 = __webpack_require__(83); | ||||||
| const util_1 = __webpack_require__(322); | const util_1 = __webpack_require__(322); | ||||||
|  | var AdoptImplementation; | ||||||
|  | (function (AdoptImplementation) { | ||||||
|  |     AdoptImplementation["Hotspot"] = "Hotspot"; | ||||||
|  |     AdoptImplementation["OpenJ9"] = "OpenJ9"; | ||||||
|  | })(AdoptImplementation = exports.AdoptImplementation || (exports.AdoptImplementation = {})); | ||||||
| class AdoptDistribution extends base_installer_1.JavaBase { | class AdoptDistribution extends base_installer_1.JavaBase { | ||||||
|     constructor(installerOptions) { |     constructor(installerOptions, jvmImpl) { | ||||||
|         super('Adopt', installerOptions); |         super(`Adopt-${jvmImpl}`, installerOptions); | ||||||
|  |         this.jvmImpl = jvmImpl; | ||||||
|     } |     } | ||||||
|     findPackageForDownload(version) { |     findPackageForDownload(version) { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
| @ -26944,6 +26955,14 @@ class AdoptDistribution extends base_installer_1.JavaBase { | |||||||
|             return { version: javaRelease.version, path: javaPath }; |             return { version: javaRelease.version, path: javaPath }; | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |     get toolcacheFolderName() { | ||||||
|  |         if (this.jvmImpl === AdoptImplementation.Hotspot) { | ||||||
|  |             // exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk"
 | ||||||
|  |             // for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063
 | ||||||
|  |             return `Java_Adopt_${this.packageType}`; | ||||||
|  |         } | ||||||
|  |         return super.toolcacheFolderName; | ||||||
|  |     } | ||||||
|     getAvailableVersions() { |     getAvailableVersions() { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             const platform = this.getPlatformOption(); |             const platform = this.getPlatformOption(); | ||||||
| @ -26956,13 +26975,13 @@ class AdoptDistribution extends base_installer_1.JavaBase { | |||||||
|                 `project=jdk`, |                 `project=jdk`, | ||||||
|                 'vendor=adoptopenjdk', |                 'vendor=adoptopenjdk', | ||||||
|                 `heap_size=normal`, |                 `heap_size=normal`, | ||||||
|                 `jvm_impl=hotspot`, |  | ||||||
|                 'sort_method=DEFAULT', |                 'sort_method=DEFAULT', | ||||||
|                 'sort_order=DESC', |                 'sort_order=DESC', | ||||||
|                 `os=${platform}`, |                 `os=${platform}`, | ||||||
|                 `architecture=${arch}`, |                 `architecture=${arch}`, | ||||||
|                 `image_type=${imageType}`, |                 `image_type=${imageType}`, | ||||||
|                 `release_type=${releaseType}` |                 `release_type=${releaseType}`, | ||||||
|  |                 `jvm_impl=${this.jvmImpl.toLowerCase()}` | ||||||
|             ].join('&'); |             ].join('&'); | ||||||
|             // need to iterate through all pages to retrieve the list of all versions
 |             // 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
 |             // Adopt API doesn't provide way to retrieve the count of pages to iterate so infinity loop
 | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ steps: | |||||||
| - uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||||
| - uses: actions/setup-java@v2 | - uses: actions/setup-java@v2 | ||||||
|   with: |   with: | ||||||
|     distribution: 'adopt' |     distribution: 'adopt-hotspot' # See 'Supported distributions' for available options @ README.md | ||||||
|     java-version: '11' |     java-version: '11' | ||||||
| - run: java -cp java HelloWorldApp | - run: java -cp java HelloWorldApp | ||||||
| ``` | ``` | ||||||
|  | |||||||
| @ -7,13 +7,20 @@ import semver from 'semver'; | |||||||
| 
 | 
 | ||||||
| import { JavaBase } from '../base-installer'; | import { JavaBase } from '../base-installer'; | ||||||
| import { IAdoptAvailableVersions } from './models'; | import { IAdoptAvailableVersions } from './models'; | ||||||
| import { JavaInstallerOptions, JavaDownloadRelease, JavaInstallerResults } from '../base-models'; | import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models'; | ||||||
| import { MACOS_JAVA_CONTENT_POSTFIX } from '../../constants'; |  | ||||||
| import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util'; | import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util'; | ||||||
| 
 | 
 | ||||||
|  | export enum AdoptImplementation { | ||||||
|  |   Hotspot = 'Hotspot', | ||||||
|  |   OpenJ9 = 'OpenJ9' | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export class AdoptDistribution extends JavaBase { | export class AdoptDistribution extends JavaBase { | ||||||
|   constructor(installerOptions: JavaInstallerOptions) { |   constructor( | ||||||
|     super('Adopt', installerOptions); |     installerOptions: JavaInstallerOptions, | ||||||
|  |     private readonly jvmImpl: AdoptImplementation | ||||||
|  |   ) { | ||||||
|  |     super(`Adopt-${jvmImpl}`, installerOptions); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   protected async findPackageForDownload(version: string): Promise<JavaDownloadRelease> { |   protected async findPackageForDownload(version: string): Promise<JavaDownloadRelease> { | ||||||
| @ -70,6 +77,15 @@ export class AdoptDistribution extends JavaBase { | |||||||
|     return { version: javaRelease.version, path: javaPath }; |     return { version: javaRelease.version, path: javaPath }; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   protected get toolcacheFolderName(): string { | ||||||
|  |     if (this.jvmImpl === AdoptImplementation.Hotspot) { | ||||||
|  |       // exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk"
 | ||||||
|  |       // for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063
 | ||||||
|  |       return `Java_Adopt_${this.packageType}`; | ||||||
|  |     } | ||||||
|  |     return super.toolcacheFolderName; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   private async getAvailableVersions(): Promise<IAdoptAvailableVersions[]> { |   private async getAvailableVersions(): Promise<IAdoptAvailableVersions[]> { | ||||||
|     const platform = this.getPlatformOption(); |     const platform = this.getPlatformOption(); | ||||||
|     const arch = this.architecture; |     const arch = this.architecture; | ||||||
| @ -83,13 +99,13 @@ export class AdoptDistribution extends JavaBase { | |||||||
|       `project=jdk`, |       `project=jdk`, | ||||||
|       'vendor=adoptopenjdk', |       'vendor=adoptopenjdk', | ||||||
|       `heap_size=normal`, |       `heap_size=normal`, | ||||||
|       `jvm_impl=hotspot`, |  | ||||||
|       'sort_method=DEFAULT', |       'sort_method=DEFAULT', | ||||||
|       'sort_order=DESC', |       'sort_order=DESC', | ||||||
|       `os=${platform}`, |       `os=${platform}`, | ||||||
|       `architecture=${arch}`, |       `architecture=${arch}`, | ||||||
|       `image_type=${imageType}`, |       `image_type=${imageType}`, | ||||||
|       `release_type=${releaseType}` |       `release_type=${releaseType}`, | ||||||
|  |       `jvm_impl=${this.jvmImpl.toLowerCase()}` | ||||||
|     ].join('&'); |     ].join('&'); | ||||||
| 
 | 
 | ||||||
|     // need to iterate through all pages to retrieve the list of all versions
 |     // need to iterate through all pages to retrieve the list of all versions
 | ||||||
|  | |||||||
| @ -1,11 +1,13 @@ | |||||||
| import { AdoptDistribution } from './adopt/installer'; |  | ||||||
| import { JavaBase } from './base-installer'; | import { JavaBase } from './base-installer'; | ||||||
| import { JavaInstallerOptions } from './base-models'; | import { JavaInstallerOptions } from './base-models'; | ||||||
| import { LocalDistribution } from './local/installer'; | import { LocalDistribution } from './local/installer'; | ||||||
| import { ZuluDistribution } from './zulu/installer'; | import { ZuluDistribution } from './zulu/installer'; | ||||||
|  | import { AdoptDistribution, AdoptImplementation } from './adopt/installer'; | ||||||
| 
 | 
 | ||||||
| enum JavaDistribution { | enum JavaDistribution { | ||||||
|   Adopt = 'adopt', |   Adopt = 'adopt', | ||||||
|  |   AdoptHotspot = 'adopt-hotspot', | ||||||
|  |   AdoptOpenJ9 = 'adopt-openj9', | ||||||
|   Zulu = 'zulu', |   Zulu = 'zulu', | ||||||
|   JdkFile = 'jdkfile' |   JdkFile = 'jdkfile' | ||||||
| } | } | ||||||
| @ -19,7 +21,10 @@ export function getJavaDistribution( | |||||||
|     case JavaDistribution.JdkFile: |     case JavaDistribution.JdkFile: | ||||||
|       return new LocalDistribution(installerOptions, jdkFile); |       return new LocalDistribution(installerOptions, jdkFile); | ||||||
|     case JavaDistribution.Adopt: |     case JavaDistribution.Adopt: | ||||||
|       return new AdoptDistribution(installerOptions); |     case JavaDistribution.AdoptHotspot: | ||||||
|  |       return new AdoptDistribution(installerOptions, AdoptImplementation.Hotspot); | ||||||
|  |     case JavaDistribution.AdoptOpenJ9: | ||||||
|  |       return new AdoptDistribution(installerOptions, AdoptImplementation.OpenJ9); | ||||||
|     case JavaDistribution.Zulu: |     case JavaDistribution.Zulu: | ||||||
|       return new ZuluDistribution(installerOptions); |       return new ZuluDistribution(installerOptions); | ||||||
|     default: |     default: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user