Fix Liberica SDKMAN patch release resolution (#1291)

* Fix Liberica SDKMAN patch release resolution

Preserve BellSoft's fourth version component as SDKMAN patch metadata and cover real API version formats for Java 17 and 25.

Fixes #1290

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d5b53868-538f-4c5f-b2aa-c66dc4ad06e2

* Fix Liberica patch ordering and build-less requests

Share overridable matching and ordering with toolcache selection. Keep patch-only requests distinct from exact SDKMAN build requests and cover the reported API pair across remote and cached resolution.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d5b53868-538f-4c5f-b2aa-c66dc4ad06e2

---------

Copilot-Session: d5b53868-538f-4c5f-b2aa-c66dc4ad06e2
This commit is contained in:
Bruno Borges
2026-10-19 10:48:21 -04:00
committed by GitHub
co-authored by Copilot App
parent b843ebf9b9
commit 816722acf8
6 changed files with 343 additions and 27 deletions
+10 -4
View File
@@ -378,7 +378,7 @@ class JavaBase {
core/* info */.pq(`Java ${foundJava.version} was downloaded`);
if (javaRelease.floating) {
if (!semver_default().valid(foundJava.version) ||
!(0,util/* isVersionSatisfies */.y)(this.version, foundJava.version)) {
!this.isVersionSatisfied(this.version, foundJava.version)) {
throw new Error(`The downloaded ${this.distribution} artifact reported Java ${foundJava.version}, which does not satisfy '${this.version}'.`);
}
javaRelease = { ...javaRelease, version: foundJava.version };
@@ -501,7 +501,7 @@ class JavaBase {
return javaRelease;
}
if (!semver_default().valid(restored.release.version) ||
!(0,util/* isVersionSatisfies */.y)(this.version, restored.release.version)) {
!this.isVersionSatisfied(this.version, restored.release.version)) {
core/* debug */.Yz(`Ignoring the cached concrete version '${restored.release.version}' for ${this.distribution} ${this.version}.`);
return javaRelease;
}
@@ -684,10 +684,10 @@ class JavaBase {
})
.filter(item => item.stable === this.stable);
const satisfiedVersions = availableVersions
.filter(item => (0,util/* isVersionSatisfies */.y)(this.version, item.version))
.filter(item => this.isVersionSatisfied(this.version, item.version))
.filter(item => item.path)
.sort((a, b) => {
return -semver_default().compareBuild(a.version, b.version);
return -this.compareVersions(a.version, b.version);
});
if (!satisfiedVersions || satisfiedVersions.length === 0) {
return null;
@@ -697,6 +697,12 @@ class JavaBase {
path: satisfiedVersions[0].path
};
}
isVersionSatisfied(range, version) {
return (0,util/* isVersionSatisfies */.y)(range, version);
}
compareVersions(a, b) {
return semver_default().compareBuild(a, b);
}
normalizeVersion(version) {
let stable = true;
const latest = false;
+38 -2
View File
@@ -52,14 +52,46 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
version: this.convertVersionToSemver(item)
}));
const satisfiedVersion = availableVersions
.filter(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .isVersionSatisfies */ .y)(range, item.version))
.sort((a, b) => -semver__WEBPACK_IMPORTED_MODULE_1___default().compareBuild(a.version, b.version))[0];
.filter(item => this.isVersionSatisfied(range, item.version))
.sort((a, b) => -this.compareVersions(a.version, b.version))[0];
if (!satisfiedVersion) {
const availableVersionStrings = availableVersions.map(item => item.version);
throw this.createVersionNotFoundError(range, availableVersionStrings);
}
return satisfiedVersion;
}
normalizeVersion(version) {
const normalized = super.normalizeVersion(version);
if (/^\d+\.\d+\.\d+\.\d+(?:-ea)?$/.test(version)) {
// Keep patch-only requests distinct from exact SDKMAN build requests.
normalized.version = version.replace(/-ea$/, '');
}
return normalized;
}
isVersionSatisfied(range, version) {
const patchRequest = range.match(/^(\d+\.\d+\.\d+)\.(\d+)$/);
if (patchRequest) {
const candidate = semver__WEBPACK_IMPORTED_MODULE_1___default().parse(version);
if (!candidate || !semver__WEBPACK_IMPORTED_MODULE_1___default().eq(patchRequest[1], candidate)) {
return false;
}
const patch = candidate.build.length > 1 ? candidate.build[0] : '0';
return patch === patchRequest[2];
}
return super.isVersionSatisfied(range, version);
}
compareVersions(a, b) {
const mainComparison = semver__WEBPACK_IMPORTED_MODULE_1___default().compare(a, b);
if (mainComparison !== 0) {
return mainComparison;
}
// SDKMAN encodes patch.build, but unpatched releases contain only build.
const patchAndBuild = (version) => {
const build = new (semver__WEBPACK_IMPORTED_MODULE_1___default().SemVer)(version).build;
return (build.length > 1 ? build : ['0', ...build]).join('.');
};
return semver__WEBPACK_IMPORTED_MODULE_1___default().compareBuild(`0.0.0+${patchAndBuild(a)}`, `0.0.0+${patchAndBuild(b)}`);
}
async getAvailableVersions() {
if (_actions_core__WEBPACK_IMPORTED_MODULE_3__/* .isDebug */ ._o()) {
console.time('Retrieving available versions for Liberica took'); // eslint-disable-line no-console
@@ -131,6 +163,10 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
const { featureVersion, interimVersion, updateVersion } = version;
const buildVersion = version.version.split('+')[1] || version.buildVersion;
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
const patchVersion = version.version.split('+')[0].split('.')[3];
if (patchVersion) {
return `${mainVersion}+${patchVersion}.${buildVersion}`;
}
if (buildVersion != 0) {
return `${mainVersion}+${buildVersion}`;
}