Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Oracle JDK download URL calculation #507

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions __tests__/distributors/oracle-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('findPackageForDownload', () => {
[
'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',
Expand All @@ -35,15 +35,15 @@ describe('findPackageForDownload', () => {
[
'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',
'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) => {
/* 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.mockReturnValue(
Promise.resolve({
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('findPackageForDownload', () => {
}
const archiveType = getDownloadArchiveExtension();
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);
}
Expand All @@ -102,8 +102,5 @@ describe('findPackageForDownload', () => {
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
/Oracle JDK is only supported for JDK 17 and later/
);
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
/Could not find Oracle JDK for SemVer */
);
});
});
12 changes: 2 additions & 10 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102973,16 +102973,8 @@ class OracleDistribution extends base_installer_1.JavaBase {
}
const platform = this.getPlatform();
const extension = util_1.getDownloadArchiveExtension();
let major;
let fileUrl;
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}`;
}
const major = range.includes('.') ? range.split('.')[0] : range;
const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
if (parseInt(major) < 17) {
throw new Error('Oracle JDK is only supported for JDK 17 and later');
}
Expand Down
11 changes: 2 additions & 9 deletions src/distributions/oracle/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,8 @@ export class OracleDistribution extends JavaBase {

const platform = this.getPlatform();
const extension = getDownloadArchiveExtension();
let major;
let fileUrl;
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}`;
}
const major = range.includes('.') ? range.split('.')[0] : range;
const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;

if (parseInt(major) < 17) {
throw new Error('Oracle JDK is only supported for JDK 17 and later');
Expand Down