mirror of
https://github.com/actions/setup-java.git
synced 2024-08-16 10:19:51 +02:00
Update Oracle JDK URL calculation
This commit is contained in:
parent
1f2faad7e0
commit
1a3cd386c6
2 changed files with 6 additions and 16 deletions
|
@ -25,7 +25,7 @@ describe('findPackageForDownload', () => {
|
||||||
[
|
[
|
||||||
'20',
|
'20',
|
||||||
'20',
|
'20',
|
||||||
'https://download.oracle.com/java/20/latest/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
'https://download.oracle.com/java/20/archive/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'20.0.1',
|
'20.0.1',
|
||||||
|
@ -35,7 +35,7 @@ describe('findPackageForDownload', () => {
|
||||||
[
|
[
|
||||||
'17',
|
'17',
|
||||||
'17',
|
'17',
|
||||||
'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
'https://download.oracle.com/java/17/archive/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'17.0.1',
|
'17.0.1',
|
||||||
|
@ -43,7 +43,7 @@ describe('findPackageForDownload', () => {
|
||||||
'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
|
||||||
]
|
]
|
||||||
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
||||||
/* Needed only for this particular test because /latest/ urls tend to change */
|
/* Needed only for this particular test because some urls might change */
|
||||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
|
||||||
spyHttpClient.mockReturnValue(
|
spyHttpClient.mockReturnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
|
@ -89,7 +89,7 @@ describe('findPackageForDownload', () => {
|
||||||
}
|
}
|
||||||
const archiveType = getDownloadArchiveExtension();
|
const archiveType = getDownloadArchiveExtension();
|
||||||
const result = await distro['findPackageForDownload'](version);
|
const result = await distro['findPackageForDownload'](version);
|
||||||
const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_${osType}-${distroArch}_bin.${archiveType}`;
|
const expectedUrl = `https://download.oracle.com/java/17/archive/jdk-17_${osType}-${distroArch}_bin.${archiveType}`;
|
||||||
|
|
||||||
expect(result.url).toBe(expectedUrl);
|
expect(result.url).toBe(expectedUrl);
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,5 @@ describe('findPackageForDownload', () => {
|
||||||
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
|
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
|
||||||
/Oracle JDK is only supported for JDK 17 and later/
|
/Oracle JDK is only supported for JDK 17 and later/
|
||||||
);
|
);
|
||||||
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
|
||||||
/Could not find Oracle JDK for SemVer */
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,15 +65,8 @@ export class OracleDistribution extends JavaBase {
|
||||||
|
|
||||||
const platform = this.getPlatform();
|
const platform = this.getPlatform();
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
let major;
|
const major = range.includes('.') ? range.split('.')[0] : range;
|
||||||
let fileUrl;
|
const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
if (range.includes('.')) {
|
|
||||||
major = range.split('.')[0];
|
|
||||||
fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
|
||||||
} else {
|
|
||||||
major = range;
|
|
||||||
fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseInt(major) < 17) {
|
if (parseInt(major) < 17) {
|
||||||
throw new Error('Oracle JDK is only supported for JDK 17 and later');
|
throw new Error('Oracle JDK is only supported for JDK 17 and later');
|
||||||
|
|
Loading…
Reference in a new issue