mirror of
https://github.com/actions/setup-java.git
synced 2026-06-24 04:57:43 +00:00
Compare commits
No commits in common. "e082345d2e97bf4aaa71924face8be3c21f4926c" and "d2b3ef8f78a868f86eea599a4afd2bbfa6334554" have entirely different histories.
e082345d2e
...
d2b3ef8f78
@ -95,7 +95,6 @@ describe('getVersionFromFileContent', () => {
|
||||
['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'],
|
||||
@ -104,41 +103,24 @@ describe('getVersionFromFileContent', () => {
|
||||
['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=11.0.25-sem', '11.0.25', 'temurin'],
|
||||
['java=17.0.13-dragonwell', '17.0.13', 'dragonwell']
|
||||
])(
|
||||
'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);
|
||||
}
|
||||
);
|
||||
])('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'
|
||||
);
|
||||
const warnSpy = jest.spyOn(require('@actions/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')
|
||||
);
|
||||
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'
|
||||
);
|
||||
const actual = getVersionFromFileContent('java=11.0.20', 'temurin', '.sdkmanrc');
|
||||
expect(actual?.version).toBe('11.0.20');
|
||||
expect(actual?.distribution).toBeUndefined();
|
||||
});
|
||||
|
||||
28
dist/cleanup/index.js
vendored
28
dist/cleanup/index.js
vendored
@ -49768,8 +49768,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||
}
|
||||
else if (versionFileName == '.sdkmanrc') {
|
||||
// Match both version and optional distribution identifier
|
||||
javaVersionRegExp =
|
||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
}
|
||||
else {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
@ -49812,19 +49811,18 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||
function mapSdkmanDistribution(sdkmanDist) {
|
||||
const distributionMap = {
|
||||
tem: 'temurin',
|
||||
sem: 'semeru',
|
||||
albba: 'dragonwell',
|
||||
zulu: 'zulu',
|
||||
amzn: 'corretto',
|
||||
graal: 'graalvm',
|
||||
graalce: 'graalvm',
|
||||
librca: 'liberica',
|
||||
ms: 'microsoft',
|
||||
oracle: 'oracle',
|
||||
sapmchn: 'sapmachine',
|
||||
jbr: 'jetbrains',
|
||||
dragonwell: 'dragonwell'
|
||||
'tem': 'temurin',
|
||||
'sem': 'temurin',
|
||||
'zulu': 'zulu',
|
||||
'amzn': 'corretto',
|
||||
'graal': 'graalvm',
|
||||
'graalce': 'graalvm',
|
||||
'librca': 'liberica',
|
||||
'ms': 'microsoft',
|
||||
'oracle': 'oracle',
|
||||
'sapmchn': 'sapmachine',
|
||||
'jbr': 'jetbrains',
|
||||
'dragonwell': 'dragonwell'
|
||||
};
|
||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||
if (!mapped) {
|
||||
|
||||
28
dist/setup/index.js
vendored
28
dist/setup/index.js
vendored
@ -87932,8 +87932,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||
}
|
||||
else if (versionFileName == '.sdkmanrc') {
|
||||
// Match both version and optional distribution identifier
|
||||
javaVersionRegExp =
|
||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
}
|
||||
else {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
@ -87976,19 +87975,18 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||
function mapSdkmanDistribution(sdkmanDist) {
|
||||
const distributionMap = {
|
||||
tem: 'temurin',
|
||||
sem: 'semeru',
|
||||
albba: 'dragonwell',
|
||||
zulu: 'zulu',
|
||||
amzn: 'corretto',
|
||||
graal: 'graalvm',
|
||||
graalce: 'graalvm',
|
||||
librca: 'liberica',
|
||||
ms: 'microsoft',
|
||||
oracle: 'oracle',
|
||||
sapmchn: 'sapmachine',
|
||||
jbr: 'jetbrains',
|
||||
dragonwell: 'dragonwell'
|
||||
'tem': 'temurin',
|
||||
'sem': 'temurin',
|
||||
'zulu': 'zulu',
|
||||
'amzn': 'corretto',
|
||||
'graal': 'graalvm',
|
||||
'graalce': 'graalvm',
|
||||
'librca': 'liberica',
|
||||
'ms': 'microsoft',
|
||||
'oracle': 'oracle',
|
||||
'sapmchn': 'sapmachine',
|
||||
'jbr': 'jetbrains',
|
||||
'dragonwell': 'dragonwell'
|
||||
};
|
||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||
if (!mapped) {
|
||||
|
||||
@ -59,9 +59,7 @@ async function run() {
|
||||
|
||||
// Use distribution from file if available, otherwise use the input
|
||||
if (versionInfo.distribution) {
|
||||
core.info(
|
||||
`Using distribution '${versionInfo.distribution}' from ${versionFile}`
|
||||
);
|
||||
core.info(`Using distribution '${versionInfo.distribution}' from ${versionFile}`);
|
||||
distributionName = versionInfo.distribution;
|
||||
} else if (!distributionName) {
|
||||
throw new Error(
|
||||
|
||||
34
src/util.ts
34
src/util.ts
@ -142,8 +142,7 @@ export function getVersionFromFileContent(
|
||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||
} else if (versionFileName == '.sdkmanrc') {
|
||||
// Match both version and optional distribution identifier
|
||||
javaVersionRegExp =
|
||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||
} else {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
}
|
||||
@ -184,11 +183,7 @@ export function getVersionFromFileContent(
|
||||
|
||||
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
||||
// (either explicitly provided or extracted from the version file) is in the list.
|
||||
if (
|
||||
DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(
|
||||
extractedDistribution || distributionName
|
||||
)
|
||||
) {
|
||||
if (DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(extractedDistribution || distributionName)) {
|
||||
const coerceVersion = semver.coerce(version) ?? version;
|
||||
version = semver.major(coerceVersion).toString();
|
||||
}
|
||||
@ -202,19 +197,18 @@ export function getVersionFromFileContent(
|
||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||
function mapSdkmanDistribution(sdkmanDist: string): string | undefined {
|
||||
const distributionMap: Record<string, string> = {
|
||||
tem: 'temurin',
|
||||
sem: 'semeru',
|
||||
albba: 'dragonwell',
|
||||
zulu: 'zulu',
|
||||
amzn: 'corretto',
|
||||
graal: 'graalvm',
|
||||
graalce: 'graalvm',
|
||||
librca: 'liberica',
|
||||
ms: 'microsoft',
|
||||
oracle: 'oracle',
|
||||
sapmchn: 'sapmachine',
|
||||
jbr: 'jetbrains',
|
||||
dragonwell: 'dragonwell'
|
||||
'tem': 'temurin',
|
||||
'sem': 'temurin',
|
||||
'zulu': 'zulu',
|
||||
'amzn': 'corretto',
|
||||
'graal': 'graalvm',
|
||||
'graalce': 'graalvm',
|
||||
'librca': 'liberica',
|
||||
'ms': 'microsoft',
|
||||
'oracle': 'oracle',
|
||||
'sapmchn': 'sapmachine',
|
||||
'jbr': 'jetbrains',
|
||||
'dragonwell': 'dragonwell'
|
||||
};
|
||||
|
||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user