Revert "Minimize diff" - restore helper methods per feedback

Agent-Logs-Url: https://github.com/nbauma109/setup-java/sessions/442a8fd6-7118-4bd0-b4f5-a2dd028d8fcd

Co-authored-by: nbauma109 <9403560+nbauma109@users.noreply.github.com>
This commit is contained in:
anthropic-code-agent[bot] 2026-04-04 09:51:51 +00:00 committed by GitHub
parent a7b700f304
commit f542c1c07f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 101 additions and 22 deletions

61
dist/setup/index.js vendored
View File

@ -114733,7 +114733,7 @@ class ZuluDistribution extends base_installer_1.JavaBase {
const satisfiedVersions = availableVersions
.filter(item => (0, util_1.isVersionSatisfies)(version, item.version))
.sort((a, b) => {
// Azul provides two versions: jdk_version and azul_version
// Azul provides two versions: java_version and distro_version
// we should sort by both fields by descending
return (-semver_1.default.compareBuild(a.version, b.version) ||
-semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion));
@ -114786,24 +114786,20 @@ class ZuluDistribution extends base_installer_1.JavaBase {
if (core.isDebug()) {
console.time('Retrieving available versions for Zulu took'); // eslint-disable-line no-console
}
// Map old API parameters to new metadata API parameters
const osParam = this.getOsParam(platform);
const archiveType = this.getArchiveType(extension);
const archParam = this.getArchParam(arch, hw_bitness);
// Fetch all pages to avoid missing packages when there are > 100 results
let allVersions = [];
let page = 1;
const pageSize = 100;
let hasMore = true;
while (hasMore) {
// Map architecture for new metadata API (x86+64bit -> x64, arm+64bit -> aarch64, etc.)
let archParam = arch;
if (arch === 'x86' && hw_bitness === '64') {
archParam = 'x64';
}
else if (arch === 'arm' && hw_bitness === '64') {
archParam = 'aarch64';
}
const requestArguments = [
`os=${platform === 'linux' ? 'linux-glibc' : platform}`,
`os=${osParam}`,
`arch=${archParam}`,
`archive_type=${extension}`,
`archive_type=${archiveType}`,
`java_package_type=${bundleType}`,
`javafx_bundled=${javafx}`,
`crac_supported=${crac}`,
@ -114861,6 +114857,49 @@ class ZuluDistribution extends base_installer_1.JavaBase {
return process.platform;
}
}
getOsParam(platform) {
// Map platform to new metadata API OS parameter
// The new API uses more specific OS names like 'linux-glibc', 'macos', 'windows'
switch (platform) {
case 'linux':
return 'linux-glibc';
case 'macos':
return 'macos';
case 'windows':
return 'windows';
default:
return platform;
}
}
getArchParam(arch, hw_bitness) {
// Map architecture to new metadata API arch parameter
// The new API uses x64, x86, aarch64, arm
if (arch === 'x86' && hw_bitness === '64') {
return 'x64';
}
else if (arch === 'x86' && hw_bitness === '32') {
return 'x86';
}
else if (arch === 'arm' && hw_bitness === '64') {
return 'aarch64';
}
else if (arch === 'arm' && hw_bitness === '') {
return 'arm';
}
// Fallback for other architectures
return arch;
}
getArchiveType(extension) {
// Map extension to archive_type parameter for new API
switch (extension) {
case 'tar.gz':
return 'tar.gz';
case 'zip':
return 'zip';
default:
return extension;
}
}
}
exports.ZuluDistribution = ZuluDistribution;

View File

@ -40,7 +40,7 @@ export class ZuluDistribution extends JavaBase {
const satisfiedVersions = availableVersions
.filter(item => isVersionSatisfies(version, item.version))
.sort((a, b) => {
// Azul provides two versions: jdk_version and azul_version
// Azul provides two versions: java_version and distro_version
// we should sort by both fields by descending
return (
-semver.compareBuild(a.version, b.version) ||
@ -112,6 +112,11 @@ export class ZuluDistribution extends JavaBase {
console.time('Retrieving available versions for Zulu took'); // eslint-disable-line no-console
}
// Map old API parameters to new metadata API parameters
const osParam = this.getOsParam(platform);
const archiveType = this.getArchiveType(extension);
const archParam = this.getArchParam(arch, hw_bitness);
// Fetch all pages to avoid missing packages when there are > 100 results
let allVersions: IZuluVersions[] = [];
let page = 1;
@ -119,18 +124,10 @@ export class ZuluDistribution extends JavaBase {
let hasMore = true;
while (hasMore) {
// Map architecture for new metadata API (x86+64bit -> x64, arm+64bit -> aarch64, etc.)
let archParam = arch;
if (arch === 'x86' && hw_bitness === '64') {
archParam = 'x64';
} else if (arch === 'arm' && hw_bitness === '64') {
archParam = 'aarch64';
}
const requestArguments = [
`os=${platform === 'linux' ? 'linux-glibc' : platform}`,
`os=${osParam}`,
`arch=${archParam}`,
`archive_type=${extension}`,
`archive_type=${archiveType}`,
`java_package_type=${bundleType}`,
`javafx_bundled=${javafx}`,
`crac_supported=${crac}`,
@ -203,4 +200,47 @@ export class ZuluDistribution extends JavaBase {
return process.platform;
}
}
private getOsParam(platform: string): string {
// Map platform to new metadata API OS parameter
// The new API uses more specific OS names like 'linux-glibc', 'macos', 'windows'
switch (platform) {
case 'linux':
return 'linux-glibc';
case 'macos':
return 'macos';
case 'windows':
return 'windows';
default:
return platform;
}
}
private getArchParam(arch: string, hw_bitness: string): string {
// Map architecture to new metadata API arch parameter
// The new API uses x64, x86, aarch64, arm
if (arch === 'x86' && hw_bitness === '64') {
return 'x64';
} else if (arch === 'x86' && hw_bitness === '32') {
return 'x86';
} else if (arch === 'arm' && hw_bitness === '64') {
return 'aarch64';
} else if (arch === 'arm' && hw_bitness === '') {
return 'arm';
}
// Fallback for other architectures
return arch;
}
private getArchiveType(extension: string): string {
// Map extension to archive_type parameter for new API
switch (extension) {
case 'tar.gz':
return 'tar.gz';
case 'zip':
return 'zip';
default:
return extension;
}
}
}