mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 20:47:43 +00:00
Make the Adoptopenjdk package type look at the Temurin repo first for latest assets
This commit is contained in:
parent
43120bc3c3
commit
bf12c838ba
@ -21,6 +21,7 @@ import {
|
|||||||
MAX_PAGINATION_PAGES,
|
MAX_PAGINATION_PAGES,
|
||||||
validatePaginationUrl
|
validatePaginationUrl
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
import {TemurinDistribution, TemurinImplementation} from '../temurin/installer';
|
||||||
|
|
||||||
export enum AdoptImplementation {
|
export enum AdoptImplementation {
|
||||||
Hotspot = 'Hotspot',
|
Hotspot = 'Hotspot',
|
||||||
@ -30,13 +31,61 @@ export enum AdoptImplementation {
|
|||||||
export class AdoptDistribution extends JavaBase {
|
export class AdoptDistribution extends JavaBase {
|
||||||
constructor(
|
constructor(
|
||||||
installerOptions: JavaInstallerOptions,
|
installerOptions: JavaInstallerOptions,
|
||||||
private readonly jvmImpl: AdoptImplementation
|
private readonly jvmImpl: AdoptImplementation,
|
||||||
|
private readonly temurinDistribution: TemurinDistribution | null = null
|
||||||
) {
|
) {
|
||||||
super(`Adopt-${jvmImpl}`, installerOptions);
|
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(
|
protected async findPackageForDownload(
|
||||||
version: string
|
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> {
|
): Promise<JavaDownloadRelease> {
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
const availableVersionsRaw = await this.getAvailableVersions();
|
||||||
const availableVersionsWithBinaries = availableVersionsRaw
|
const availableVersionsWithBinaries = availableVersionsRaw
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
super(`Temurin-${jvmImpl}`, installerOptions);
|
super(`Temurin-${jvmImpl}`, installerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
public async findPackageForDownload(
|
||||||
version: string
|
version: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
const availableVersionsRaw = await this.getAvailableVersions();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user