mirror of
https://github.com/actions/setup-java.git
synced 2026-07-04 19:35:42 +00:00
Compare commits
1 Commits
0444343a59
...
89ab790378
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89ab790378 |
@ -1,17 +1,11 @@
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import {
|
import {AdoptDistribution, AdoptImplementation} from '../../src/distributions/adopt/installer';
|
||||||
AdoptDistribution,
|
|
||||||
AdoptImplementation
|
|
||||||
} from '../../src/distributions/adopt/installer';
|
|
||||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import manifestData from '../data/adopt.json';
|
import manifestData from '../data/adopt.json';
|
||||||
import {
|
import {TemurinDistribution, TemurinImplementation} from "../../src/distributions/temurin/installer";
|
||||||
TemurinDistribution,
|
|
||||||
TemurinImplementation
|
|
||||||
} from '../../src/distributions/temurin/installer';
|
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
let spyHttpClient: jest.SpyInstance;
|
let spyHttpClient: jest.SpyInstance;
|
||||||
@ -264,6 +258,7 @@ 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 temurinDistribution = new TemurinDistribution(
|
const temurinDistribution = new TemurinDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
@ -285,19 +280,18 @@ describe('findPackageForDownload', () => {
|
|||||||
temurinDistribution
|
temurinDistribution
|
||||||
);
|
);
|
||||||
|
|
||||||
temurinDistribution['getAvailableVersions'] = async () =>
|
temurinDistribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
manifestData as any;
|
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
|
||||||
input
|
|
||||||
);
|
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('Falls back if Temurin fails', () => {
|
describe('Falls back if Temurin fails', () => {
|
||||||
it.each([['9', '9.0.7+10']])(
|
it.each([
|
||||||
'version is resolved correctly %s -> %s',
|
['9', '9.0.7+10']
|
||||||
async (input, expected) => {
|
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||||
|
|
||||||
const temurinDistribution = new TemurinDistribution(
|
const temurinDistribution = new TemurinDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
@ -319,18 +313,14 @@ describe('findPackageForDownload', () => {
|
|||||||
temurinDistribution
|
temurinDistribution
|
||||||
);
|
);
|
||||||
|
|
||||||
temurinDistribution['findPackageForDownload'] = async () =>
|
temurinDistribution['findPackageForDownload'] = async () => new Promise(function () {
|
||||||
new Promise(function () {
|
throw new Error("Could not find satisfied version for SemVer")
|
||||||
throw new Error('Could not find satisfied version for SemVer');
|
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
|
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
||||||
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 () => {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import {
|
|||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {TemurinDistribution, TemurinImplementation} from '../temurin/installer';
|
import {TemurinDistribution, TemurinImplementation} from "../temurin/installer";
|
||||||
|
|
||||||
export enum AdoptImplementation {
|
export enum AdoptImplementation {
|
||||||
Hotspot = 'Hotspot',
|
Hotspot = 'Hotspot',
|
||||||
@ -33,45 +33,36 @@ export class AdoptDistribution extends JavaBase {
|
|||||||
super(`Adopt-${jvmImpl}`, installerOptions);
|
super(`Adopt-${jvmImpl}`, installerOptions);
|
||||||
|
|
||||||
if (temurinDistribution != null && jvmImpl != AdoptImplementation.Hotspot) {
|
if (temurinDistribution != null && jvmImpl != AdoptImplementation.Hotspot) {
|
||||||
throw new Error('Only Hotspot JVM is supported by Temurin.');
|
throw new Error("Only Hotspot JVM is supported by Temurin.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only use the temurin repo for Hotspot JVMs
|
// Only use the temurin repo for Hotspot JVMs
|
||||||
if (temurinDistribution == null && jvmImpl == AdoptImplementation.Hotspot) {
|
if (temurinDistribution == null && jvmImpl == AdoptImplementation.Hotspot) {
|
||||||
this.temurinDistribution = new TemurinDistribution(
|
this.temurinDistribution = new TemurinDistribution(
|
||||||
installerOptions,
|
installerOptions,
|
||||||
TemurinImplementation.Hotspot
|
TemurinImplementation.Hotspot);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
protected async findPackageForDownload(
|
||||||
version: string
|
version: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
|
|
||||||
if (this.jvmImpl == AdoptImplementation.Hotspot) {
|
if (this.jvmImpl == AdoptImplementation.Hotspot) {
|
||||||
core.notice(
|
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.")
|
||||||
"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 (
|
if (this.jvmImpl == AdoptImplementation.Hotspot && this.temurinDistribution != null) {
|
||||||
this.jvmImpl == AdoptImplementation.Hotspot &&
|
|
||||||
this.temurinDistribution != null
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
let result = await this.temurinDistribution.findPackageForDownload(
|
let result = await this.temurinDistribution.findPackageForDownload(version)
|
||||||
version
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result != undefined) {
|
if (result != undefined) {
|
||||||
return result;
|
return result
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message.includes('Could not find satisfied version')) {
|
if (error.message.includes('Could not find satisfied version')) {
|
||||||
core.notice(
|
core.notice("The JVM you are looking for could not be found in the Temurin repository, this likely indicates " +
|
||||||
'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.")
|
||||||
'that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user