mirror of
https://github.com/actions/setup-java.git
synced 2026-07-08 16:20:44 +03:00
feat: Add distribution detection support to .sdkmanrc file (#975)
* feat: Add distribution detection support to .sdkmanrc file Extends .sdkmanrc support to automatically detect Java distribution from SDKMAN identifiers (e.g., java=21.0.5-tem maps to temurin distribution). Makes distribution input optional when using .sdkmanrc with distribution suffix. * fix: align SDKMAN sem identifier mapping * fix: support SDKMAN albba identifier * docs: clarify sdkmanrc distribution inference scope Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Tencent Kona SDKMAN mapping and format sdkmanrc docs as a table - Map SDKMAN 'kona' identifier to the 'kona' distribution (added in #672) - Add a .sdkmanrc test case for the kona suffix - Convert the inline SDKMAN suffix mapping in advanced-usage.md to a table - Rebuild dist bundles Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Bruno Borges <bruno.borges@gmail.com>
This commit is contained in:
+55
-10
@@ -166,15 +166,60 @@ describe('validatePaginationUrl', () => {
|
||||
describe('getVersionFromFileContent', () => {
|
||||
describe('.sdkmanrc', () => {
|
||||
it.each([
|
||||
['java=11.0.20.1-tem', '11.0.20'],
|
||||
['java = 11.0.20.1-tem', '11.0.20'],
|
||||
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20'],
|
||||
['java=11.0.20.1-tem\n#java=21.0.20.1-tem\n', '11.0.20'], // choose first match
|
||||
['java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '11.0.20'], // choose first match
|
||||
['#java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '21.0.20'] // first one is 'commented' in .sdkmanrc
|
||||
])('parsing %s should return %s', (content: string, expected: string) => {
|
||||
const actual = getVersionFromFileContent(content, 'openjdk', '.sdkmanrc');
|
||||
expect(actual).toBe(expected);
|
||||
['java=11.0.20.1-tem', '11.0.20', 'temurin'],
|
||||
['java = 11.0.20.1-tem', '11.0.20', 'temurin'],
|
||||
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20', 'temurin'],
|
||||
['java=11.0.20.1-tem\n#java=21.0.20.1-tem\n', '11.0.20', 'temurin'], // choose first match
|
||||
['java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '11.0.20', 'temurin'], // choose first match
|
||||
['#java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '21.0.20', 'temurin'], // first one is 'commented' in .sdkmanrc
|
||||
['java=21.0.5-zulu', '21.0.5', 'zulu'],
|
||||
['java=17.0.13-albba', '17.0.13', 'dragonwell'],
|
||||
['java=17.0.13-amzn', '17', 'corretto'],
|
||||
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
||||
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
|
||||
['java=11.0.25-librca', '11.0.25', 'liberica'],
|
||||
['java=11.0.25-ms', '11.0.25', 'microsoft'],
|
||||
['java=21.0.5-oracle', '21.0.5', 'oracle'],
|
||||
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
||||
['java=21.0.5-jbr', '21.0.5', 'jetbrains'],
|
||||
['java=11.0.25-sem', '11.0.25', 'semeru'],
|
||||
['java=17.0.13-dragonwell', '17.0.13', 'dragonwell'],
|
||||
['java=21.0.5-kona', '21.0.5', 'kona']
|
||||
])(
|
||||
'parsing %s should return version %s and distribution %s',
|
||||
(content: string, expectedVersion: string, expectedDist: string) => {
|
||||
const actual = getVersionFromFileContent(
|
||||
content,
|
||||
'openjdk',
|
||||
'.sdkmanrc'
|
||||
);
|
||||
expect(actual?.version).toBe(expectedVersion);
|
||||
expect(actual?.distribution).toBe(expectedDist);
|
||||
}
|
||||
);
|
||||
|
||||
it('should warn and return undefined distribution for unknown identifier', () => {
|
||||
const warnSpy = jest.spyOn(core, 'warning');
|
||||
const actual = getVersionFromFileContent(
|
||||
'java=21.0.5-unknown',
|
||||
'temurin',
|
||||
'.sdkmanrc'
|
||||
);
|
||||
expect(actual?.version).toBe('21.0.5');
|
||||
expect(actual?.distribution).toBeUndefined();
|
||||
expect(warnSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Unknown SDKMAN distribution identifier')
|
||||
);
|
||||
});
|
||||
|
||||
it('should return version without distribution when no suffix provided', () => {
|
||||
const actual = getVersionFromFileContent(
|
||||
'java=11.0.20',
|
||||
'temurin',
|
||||
'.sdkmanrc'
|
||||
);
|
||||
expect(actual?.version).toBe('11.0.20');
|
||||
expect(actual?.distribution).toBeUndefined();
|
||||
});
|
||||
|
||||
describe('known versions', () => {
|
||||
@@ -193,7 +238,7 @@ describe('getVersionFromFileContent', () => {
|
||||
'openjdk',
|
||||
'.sdkmanrc'
|
||||
);
|
||||
expect(actual).toBe(expected);
|
||||
expect(actual?.version).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user