Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 868
Make the Adoptopenjdk package type look at the Temurin repo first for latest assets#522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
bf12c837d2d4565d3f136d8f95beb8110ec4826c07041d924File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,22 +21,80 @@ import { | ||
| MAX_PAGINATION_PAGES, | ||
| validatePaginationUrl | ||
| } from '../../util'; | ||
| import {TemurinDistribution, TemurinImplementation} from '../temurin/installer'; | ||
| export enum AdoptImplementation { | ||
| Hotspot = 'Hotspot', | ||
| OpenJ9 = 'OpenJ9' | ||
| } | ||
| export class AdoptDistribution extends JavaBase { | ||
| private readonly temurinDistribution: TemurinDistribution | null; | ||
| constructor( | ||
| installerOptions: JavaInstallerOptions, | ||
| private readonly jvmImpl: AdoptImplementation | ||
| private readonly jvmImpl: AdoptImplementation, | ||
| temurinDistribution: TemurinDistribution | null = null | ||
| ) { | ||
| super(`Adopt-${jvmImpl}`, installerOptions); | ||
| if ( | ||
| temurinDistribution !== null && | ||
| jvmImpl !== AdoptImplementation.Hotspot | ||
| ) { | ||
| throw new Error('Only Hotspot JVM is supported by Temurin.'); | ||
| } | ||
| // Only use the temurin repo for Hotspot JVMs | ||
| this.temurinDistribution = | ||
| temurinDistribution ?? | ||
| (jvmImpl === AdoptImplementation.Hotspot | ||
| ? new TemurinDistribution( | ||
| installerOptions, | ||
| TemurinImplementation.Hotspot | ||
| ) | ||
| : null); | ||
| } | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| protected async findPackageForDownload( | ||
| version: string | ||
| ): Promise<JavaDownloadRelease> { | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (this.jvmImpl === AdoptImplementation.Hotspot) { | ||
| core.notice( | ||
| "AdoptOpenJDK has moved to Eclipse Temurin https://github.com/actions/setup-java#supported-distributions please consider changing to the 'temurin' distribution type in your setup-java configuration." | ||
| ); | ||
| } | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if ( | ||
| this.jvmImpl === AdoptImplementation.Hotspot && | ||
| this.temurinDistribution !== null | ||
| ) { | ||
| try { | ||
| return await this.temurinDistribution.findPackageForDownload(version); | ||
| } catch (error) { | ||
| // Log the failure but always fall back to legacy AdoptOpenJDK for resilience | ||
| const errorMessage = | ||
| error instanceof Error ? error.message : String(error); | ||
| if (error instanceof Error && error.name === 'VersionNotFoundError') { | ||
| core.notice( | ||
| 'The JVM you are looking for could not be found in the Temurin repository, this likely indicates ' + | ||
| 'that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.' | ||
| ); | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } else { | ||
| // Log other errors for debugging but gracefully fall back | ||
| core.debug( | ||
| `Temurin lookup failed: ${errorMessage}. Falling back to AdoptOpenJDK API.` | ||
| ); | ||
| } | ||
| } | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| // failed to find a Temurin version, so fall back to AdoptOpenJDK | ||
| return this.findPackageForDownloadOldAdoptOpenJdk(version); | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| private async findPackageForDownloadOldAdoptOpenJdk( | ||
| version: string | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ): Promise<JavaDownloadRelease> { | ||
| const availableVersionsRaw = await this.getAvailableVersions(); | ||
| const availableVersionsWithBinaries = availableVersionsRaw | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -34,7 +34,10 @@ export class TemurinDistribution extends JavaBase { | ||
| super(`Temurin-${jvmImpl}`, installerOptions); | ||
| } | ||
| protected async findPackageForDownload( | ||
| /** | ||
| * @internal For cross-distribution reuse only. Not intended as a public API. | ||
| */ | ||
| public async findPackageForDownload( | ||
johnoliver marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| version: string | ||
| ): Promise<JavaDownloadRelease> { | ||
gdams marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const availableVersionsRaw = await this.getAvailableVersions(); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.