mirror of
https://github.com/actions/setup-java.git
synced 2026-06-28 16:07:51 +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', '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=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=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=17.0.13-amzn', '17', 'corretto'],
|
||||||
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
||||||
['java=17.0.9-graalce', '17.0.9', '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=21.0.5-oracle', '21.0.5', 'oracle'],
|
||||||
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
||||||
['java=21.0.5-jbr', '21.0.5', 'jetbrains'],
|
['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']
|
['java=17.0.13-dragonwell', '17.0.13', 'dragonwell']
|
||||||
])(
|
])('parsing %s should return version %s and distribution %s', (content: string, expectedVersion: string, expectedDist: string) => {
|
||||||
'parsing %s should return version %s and distribution %s',
|
const actual = getVersionFromFileContent(content, 'openjdk', '.sdkmanrc');
|
||||||
(content: string, expectedVersion: string, expectedDist: string) => {
|
expect(actual?.version).toBe(expectedVersion);
|
||||||
const actual = getVersionFromFileContent(
|
expect(actual?.distribution).toBe(expectedDist);
|
||||||
content,
|
});
|
||||||
'openjdk',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe(expectedVersion);
|
|
||||||
expect(actual?.distribution).toBe(expectedDist);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should warn and return undefined distribution for unknown identifier', () => {
|
it('should warn and return undefined distribution for unknown identifier', () => {
|
||||||
const warnSpy = jest.spyOn(core, 'warning');
|
const warnSpy = jest.spyOn(require('@actions/core'), 'warning');
|
||||||
const actual = getVersionFromFileContent(
|
const actual = getVersionFromFileContent('java=21.0.5-unknown', 'temurin', '.sdkmanrc');
|
||||||
'java=21.0.5-unknown',
|
|
||||||
'temurin',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe('21.0.5');
|
expect(actual?.version).toBe('21.0.5');
|
||||||
expect(actual?.distribution).toBeUndefined();
|
expect(actual?.distribution).toBeUndefined();
|
||||||
expect(warnSpy).toHaveBeenCalledWith(
|
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Unknown SDKMAN distribution identifier'));
|
||||||
expect.stringContaining('Unknown SDKMAN distribution identifier')
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return version without distribution when no suffix provided', () => {
|
it('should return version without distribution when no suffix provided', () => {
|
||||||
const actual = getVersionFromFileContent(
|
const actual = getVersionFromFileContent('java=11.0.20', 'temurin', '.sdkmanrc');
|
||||||
'java=11.0.20',
|
|
||||||
'temurin',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe('11.0.20');
|
expect(actual?.version).toBe('11.0.20');
|
||||||
expect(actual?.distribution).toBeUndefined();
|
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') {
|
else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
// Match both version and optional distribution identifier
|
||||||
javaVersionRegExp =
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
@ -49812,19 +49811,18 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
|||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||||
function mapSdkmanDistribution(sdkmanDist) {
|
function mapSdkmanDistribution(sdkmanDist) {
|
||||||
const distributionMap = {
|
const distributionMap = {
|
||||||
tem: 'temurin',
|
'tem': 'temurin',
|
||||||
sem: 'semeru',
|
'sem': 'temurin',
|
||||||
albba: 'dragonwell',
|
'zulu': 'zulu',
|
||||||
zulu: 'zulu',
|
'amzn': 'corretto',
|
||||||
amzn: 'corretto',
|
'graal': 'graalvm',
|
||||||
graal: 'graalvm',
|
'graalce': 'graalvm',
|
||||||
graalce: 'graalvm',
|
'librca': 'liberica',
|
||||||
librca: 'liberica',
|
'ms': 'microsoft',
|
||||||
ms: 'microsoft',
|
'oracle': 'oracle',
|
||||||
oracle: 'oracle',
|
'sapmchn': 'sapmachine',
|
||||||
sapmchn: 'sapmachine',
|
'jbr': 'jetbrains',
|
||||||
jbr: 'jetbrains',
|
'dragonwell': 'dragonwell'
|
||||||
dragonwell: 'dragonwell'
|
|
||||||
};
|
};
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||||
if (!mapped) {
|
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') {
|
else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
// Match both version and optional distribution identifier
|
||||||
javaVersionRegExp =
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
@ -87976,19 +87975,18 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
|
|||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||||
function mapSdkmanDistribution(sdkmanDist) {
|
function mapSdkmanDistribution(sdkmanDist) {
|
||||||
const distributionMap = {
|
const distributionMap = {
|
||||||
tem: 'temurin',
|
'tem': 'temurin',
|
||||||
sem: 'semeru',
|
'sem': 'temurin',
|
||||||
albba: 'dragonwell',
|
'zulu': 'zulu',
|
||||||
zulu: 'zulu',
|
'amzn': 'corretto',
|
||||||
amzn: 'corretto',
|
'graal': 'graalvm',
|
||||||
graal: 'graalvm',
|
'graalce': 'graalvm',
|
||||||
graalce: 'graalvm',
|
'librca': 'liberica',
|
||||||
librca: 'liberica',
|
'ms': 'microsoft',
|
||||||
ms: 'microsoft',
|
'oracle': 'oracle',
|
||||||
oracle: 'oracle',
|
'sapmchn': 'sapmachine',
|
||||||
sapmchn: 'sapmachine',
|
'jbr': 'jetbrains',
|
||||||
jbr: 'jetbrains',
|
'dragonwell': 'dragonwell'
|
||||||
dragonwell: 'dragonwell'
|
|
||||||
};
|
};
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||||
if (!mapped) {
|
if (!mapped) {
|
||||||
|
|||||||
@ -59,9 +59,7 @@ async function run() {
|
|||||||
|
|
||||||
// Use distribution from file if available, otherwise use the input
|
// Use distribution from file if available, otherwise use the input
|
||||||
if (versionInfo.distribution) {
|
if (versionInfo.distribution) {
|
||||||
core.info(
|
core.info(`Using distribution '${versionInfo.distribution}' from ${versionFile}`);
|
||||||
`Using distribution '${versionInfo.distribution}' from ${versionFile}`
|
|
||||||
);
|
|
||||||
distributionName = versionInfo.distribution;
|
distributionName = versionInfo.distribution;
|
||||||
} else if (!distributionName) {
|
} else if (!distributionName) {
|
||||||
throw new Error(
|
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;
|
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||||
} else if (versionFileName == '.sdkmanrc') {
|
} else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
// Match both version and optional distribution identifier
|
||||||
javaVersionRegExp =
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
} else {
|
} else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
}
|
}
|
||||||
@ -184,11 +183,7 @@ export function getVersionFromFileContent(
|
|||||||
|
|
||||||
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
||||||
// (either explicitly provided or extracted from the version file) is in the list.
|
// (either explicitly provided or extracted from the version file) is in the list.
|
||||||
if (
|
if (DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(extractedDistribution || distributionName)) {
|
||||||
DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(
|
|
||||||
extractedDistribution || distributionName
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
const coerceVersion = semver.coerce(version) ?? version;
|
const coerceVersion = semver.coerce(version) ?? version;
|
||||||
version = semver.major(coerceVersion).toString();
|
version = semver.major(coerceVersion).toString();
|
||||||
}
|
}
|
||||||
@ -202,19 +197,18 @@ export function getVersionFromFileContent(
|
|||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
// Map SDKMAN distribution identifiers to setup-java distribution names
|
||||||
function mapSdkmanDistribution(sdkmanDist: string): string | undefined {
|
function mapSdkmanDistribution(sdkmanDist: string): string | undefined {
|
||||||
const distributionMap: Record<string, string> = {
|
const distributionMap: Record<string, string> = {
|
||||||
tem: 'temurin',
|
'tem': 'temurin',
|
||||||
sem: 'semeru',
|
'sem': 'temurin',
|
||||||
albba: 'dragonwell',
|
'zulu': 'zulu',
|
||||||
zulu: 'zulu',
|
'amzn': 'corretto',
|
||||||
amzn: 'corretto',
|
'graal': 'graalvm',
|
||||||
graal: 'graalvm',
|
'graalce': 'graalvm',
|
||||||
graalce: 'graalvm',
|
'librca': 'liberica',
|
||||||
librca: 'liberica',
|
'ms': 'microsoft',
|
||||||
ms: 'microsoft',
|
'oracle': 'oracle',
|
||||||
oracle: 'oracle',
|
'sapmchn': 'sapmachine',
|
||||||
sapmchn: 'sapmachine',
|
'jbr': 'jetbrains',
|
||||||
jbr: 'jetbrains',
|
'dragonwell': 'dragonwell'
|
||||||
dragonwell: 'dragonwell'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user