From bf12c838ba3f0730c02c0f89b54be42d596538d3 Mon Sep 17 00:00:00 2001 From: John <1615532+johnoliver@users.noreply.github.com> Date: Fri, 12 Jun 2026 11:39:34 +0000 Subject: [PATCH] Make the Adoptopenjdk package type look at the Temurin repo first for latest assets --- src/distributions/adopt/installer.ts | 51 +++++++++++++++++++++++++- src/distributions/temurin/installer.ts | 2 +- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/distributions/adopt/installer.ts b/src/distributions/adopt/installer.ts index b6393f72..36dde7ab 100644 --- a/src/distributions/adopt/installer.ts +++ b/src/distributions/adopt/installer.ts @@ -21,6 +21,7 @@ import { MAX_PAGINATION_PAGES, validatePaginationUrl } from '../../util'; +import {TemurinDistribution, TemurinImplementation} from '../temurin/installer'; export enum AdoptImplementation { Hotspot = 'Hotspot', @@ -30,13 +31,61 @@ export enum AdoptImplementation { export class AdoptDistribution extends JavaBase { constructor( installerOptions: JavaInstallerOptions, - private readonly jvmImpl: AdoptImplementation + private readonly jvmImpl: AdoptImplementation, + private readonly 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 + if (temurinDistribution == null && jvmImpl == AdoptImplementation.Hotspot) { + this.temurinDistribution = new TemurinDistribution( + installerOptions, + TemurinImplementation.Hotspot + ); + } } protected async findPackageForDownload( version: string + ): Promise { + 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." + ); + } + + if ( + this.jvmImpl == AdoptImplementation.Hotspot && + this.temurinDistribution != null + ) { + try { + const result = await this.temurinDistribution.findPackageForDownload( + version + ); + + if (result != undefined) { + return result; + } + } catch (error) { + if (error.message.includes('Could not find satisfied version')) { + 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.' + ); + } + } + } + + // failed to find a Temurin version, so fall back to AdoptOpenJDK + return this.findPackageForDownloadOldAdoptOpenJdk(version); + } + + private async findPackageForDownloadOldAdoptOpenJdk( + version: string ): Promise { const availableVersionsRaw = await this.getAvailableVersions(); const availableVersionsWithBinaries = availableVersionsRaw diff --git a/src/distributions/temurin/installer.ts b/src/distributions/temurin/installer.ts index 7e5617cb..d16d938d 100644 --- a/src/distributions/temurin/installer.ts +++ b/src/distributions/temurin/installer.ts @@ -34,7 +34,7 @@ export class TemurinDistribution extends JavaBase { super(`Temurin-${jvmImpl}`, installerOptions); } - protected async findPackageForDownload( + public async findPackageForDownload( version: string ): Promise { const availableVersionsRaw = await this.getAvailableVersions();