Make the Adoptopenjdk package type look at the Temurin repo first for latest assets

This commit is contained in:
John 2026-06-12 11:39:34 +00:00
parent 43120bc3c3
commit bf12c838ba
2 changed files with 51 additions and 2 deletions

View File

@ -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<JavaDownloadRelease> {
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<JavaDownloadRelease> {
const availableVersionsRaw = await this.getAvailableVersions();
const availableVersionsWithBinaries = availableVersionsRaw

View File

@ -34,7 +34,7 @@ export class TemurinDistribution extends JavaBase {
super(`Temurin-${jvmImpl}`, installerOptions);
}
protected async findPackageForDownload(
public async findPackageForDownload(
version: string
): Promise<JavaDownloadRelease> {
const availableVersionsRaw = await this.getAvailableVersions();