Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions __tests__/distributors/base-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,9 @@ describe('normalizeVersion', () => {
['11.0.9.1', {version: '11.0.9+1', stable: true, latest: false}],
['12.0.2.1.0', {version: '12.0.2+1.0', stable: true, latest: false}],
['18.0.1.1-ea', {version: '18.0.1+1', stable: false, latest: false}],
['26.0.2.1+1', {version: '26.0.2+1.1', stable: true, latest: false}],
['25.0.4.1+1', {version: '25.0.4+1.1', stable: true, latest: false}],
['26.0.2+10', {version: '26.0.2+10', stable: true, latest: false}],
['latest', {version: 'x', stable: true, latest: true}],
['LATEST', {version: 'x', stable: true, latest: true}],
[' Latest ', {version: 'x', stable: true, latest: true}]
Expand Down
5 changes: 4 additions & 1 deletion __tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ describe('convertVersionToSemver', () => {
['12.0', '12.0'],
['12.0.2', '12.0.2'],
['12.0.2.1', '12.0.2+1'],
['12.0.2.1.0', '12.0.2+1.0']
['12.0.2.1.0', '12.0.2+1.0'],
['26.0.2.1+1', '26.0.2+1.1'],
['25.0.4.1+1', '25.0.4+1.1'],
['26.0.2+10', '26.0.2+10']
])('%s -> %s', (input: string, expected: string) => {
const actual = convertVersionToSemver(input);
expect(actual).toBe(expected);
Expand Down
23 changes: 19 additions & 4 deletions dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31239,13 +31239,28 @@ function avoidOldNotation(content) {
return content.startsWith('1.') ? content.substring(2) : content;
}
function convertVersionToSemver(version) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1).
// Temurin also publishes four-field versions that already carry build
// metadata (26.0.2.1+1). Preserve that +build by folding the extra numeric
// fields into SemVer build metadata alongside it.
if (Array.isArray(version)) {
const mainVersion = version.slice(0, 3).join('.');
if (version.length > 3) {
return `${mainVersion}+${version.slice(3).join('.')}`;
}
return mainVersion;
}
const plusIndex = version.indexOf('+');
const core = plusIndex >= 0 ? version.slice(0, plusIndex) : version;
const existingBuild = plusIndex >= 0 ? version.slice(plusIndex + 1) : '';
const versionArray = core.split('.');
const mainVersion = versionArray.slice(0, 3).join('.');
if (versionArray.length > 3) {
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
const fromFields = versionArray.slice(3).join('.');
const mergedBuild = [fromFields, existingBuild].filter(Boolean).join('.');
return `${mainVersion}+${mergedBuild}`;
}
return mainVersion;
return existingBuild ? `${mainVersion}+${existingBuild}` : mainVersion;
}
/**
* Builds a validator for the bytes currently served by a URL from the response
Expand Down
7 changes: 4 additions & 3 deletions dist/setup/242.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,10 @@ class JavaBase {
// Java uses a versioning scheme (JEP 322) that can contain more numeric
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
// exact versions to SemVer build notation ('18.0.1+1') so they are
// accepted. Ranges and versions that already carry build metadata are
// left untouched.
if (/^\d+(\.\d+){3,}$/.test(version)) {
// accepted. Also cover four-field versions that already include +build
// metadata (Temurin: '26.0.2.1+1' -> '26.0.2+1.1'). Ranges with fewer
// than four numeric fields are left untouched.
if (/^\d+(\.\d+){3,}(\+.*)?$/.test(version)) {
version = (0,util/* convertVersionToSemver */.ZY)(version);
}
if (!semver_default().validRange(version)) {
Expand Down
23 changes: 19 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31696,13 +31696,28 @@ function avoidOldNotation(content) {
return content.startsWith('1.') ? content.substring(2) : content;
}
function convertVersionToSemver(version) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1).
// Temurin also publishes four-field versions that already carry build
// metadata (26.0.2.1+1). Preserve that +build by folding the extra numeric
// fields into SemVer build metadata alongside it.
if (Array.isArray(version)) {
const mainVersion = version.slice(0, 3).join('.');
if (version.length > 3) {
return `${mainVersion}+${version.slice(3).join('.')}`;
}
return mainVersion;
}
const plusIndex = version.indexOf('+');
const core = plusIndex >= 0 ? version.slice(0, plusIndex) : version;
const existingBuild = plusIndex >= 0 ? version.slice(plusIndex + 1) : '';
const versionArray = core.split('.');
const mainVersion = versionArray.slice(0, 3).join('.');
if (versionArray.length > 3) {
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
const fromFields = versionArray.slice(3).join('.');
const mergedBuild = [fromFields, existingBuild].filter(Boolean).join('.');
return `${mainVersion}+${mergedBuild}`;
}
return mainVersion;
return existingBuild ? `${mainVersion}+${existingBuild}` : mainVersion;
}
/**
* Builds a validator for the bytes currently served by a URL from the response
Expand Down
7 changes: 4 additions & 3 deletions src/distributions/base-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,10 @@ export abstract class JavaBase {
// Java uses a versioning scheme (JEP 322) that can contain more numeric
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
// exact versions to SemVer build notation ('18.0.1+1') so they are
// accepted. Ranges and versions that already carry build metadata are
// left untouched.
if (/^\d+(\.\d+){3,}$/.test(version)) {
// accepted. Also cover four-field versions that already include +build
// metadata (Temurin: '26.0.2.1+1' -> '26.0.2+1.1'). Ranges with fewer
// than four numeric fields are left untouched.
if (/^\d+(\.\d+){3,}(\+.*)?$/.test(version)) {
version = convertVersionToSemver(version);
}

Expand Down
24 changes: 20 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,29 @@ function avoidOldNotation(content: string): string {
}

export function convertVersionToSemver(version: number[] | string) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1).
// Temurin also publishes four-field versions that already carry build
// metadata (26.0.2.1+1). Preserve that +build by folding the extra numeric
// fields into SemVer build metadata alongside it.
if (Array.isArray(version)) {
const mainVersion = version.slice(0, 3).join('.');
if (version.length > 3) {
return `${mainVersion}+${version.slice(3).join('.')}`;
}
return mainVersion;
}

const plusIndex = version.indexOf('+');
const core = plusIndex >= 0 ? version.slice(0, plusIndex) : version;
const existingBuild = plusIndex >= 0 ? version.slice(plusIndex + 1) : '';
const versionArray = core.split('.');
const mainVersion = versionArray.slice(0, 3).join('.');
if (versionArray.length > 3) {
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
const fromFields = versionArray.slice(3).join('.');
const mergedBuild = [fromFields, existingBuild].filter(Boolean).join('.');
return `${mainVersion}+${mergedBuild}`;
}
return mainVersion;
return existingBuild ? `${mainVersion}+${existingBuild}` : mainVersion;
}

/**
Expand Down