mirror of
https://gitea.com/actions/setup-java.git
synced 2025-11-29 18:01:16 +08:00
feat: Add support for .sdkmanrc file in java-version-file parameter (#736)
* chore(e2e-versions): Add e2e test scenario on `setup-java-version-from-file-major-minor-patch-with-dist` for `.sdkmanrc` * chore(e2e-versions): Update `setup-java-version-from-file-major-minor-patch-with-dist` test to include the file name of the java-version-file that is used * feat: Add support for `.sdkmanrc` as *Java Version File* * chore: Add test for the latest known sdkman java versions * docs(advanced-usage): Document support for `.sdkmanrc` as java-version-file * chore(docs): Anyone can contribute and maintain 🤷 * Update advanced-usage.md Add example step/file for `.sdkmanrc` * Update advanced-usage.md * Update util.ts * chore: format and rebuild * chore: untouch toolchains.ts * fix check dist error --------- Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
This commit is contained in:
11
dist/cleanup/index.js
vendored
11
dist/cleanup/index.js
vendored
@@ -94706,17 +94706,20 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||
javaVersionRegExp =
|
||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||
}
|
||||
else if (versionFileName == '.sdkmanrc') {
|
||||
javaVersionRegExp = /^java\s*=\s*(?<version>[^-]+)/m;
|
||||
}
|
||||
else {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
}
|
||||
const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||
const capturedVersion = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||
: '';
|
||||
if (!fileContent) {
|
||||
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||
if (!capturedVersion) {
|
||||
return null;
|
||||
}
|
||||
core.debug(`Version from file '${fileContent}'`);
|
||||
const tentativeVersion = avoidOldNotation(fileContent);
|
||||
const tentativeVersion = avoidOldNotation(capturedVersion);
|
||||
const rawVersion = tentativeVersion.split('-')[0];
|
||||
let version = semver.validRange(rawVersion)
|
||||
? tentativeVersion
|
||||
|
||||
11
dist/setup/index.js
vendored
11
dist/setup/index.js
vendored
@@ -132850,17 +132850,20 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||
javaVersionRegExp =
|
||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||
}
|
||||
else if (versionFileName == '.sdkmanrc') {
|
||||
javaVersionRegExp = /^java\s*=\s*(?<version>[^-]+)/m;
|
||||
}
|
||||
else {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
}
|
||||
const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||
const capturedVersion = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||
: '';
|
||||
if (!fileContent) {
|
||||
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||
if (!capturedVersion) {
|
||||
return null;
|
||||
}
|
||||
core.debug(`Version from file '${fileContent}'`);
|
||||
const tentativeVersion = avoidOldNotation(fileContent);
|
||||
const tentativeVersion = avoidOldNotation(capturedVersion);
|
||||
const rawVersion = tentativeVersion.split('-')[0];
|
||||
let version = semver.validRange(rawVersion)
|
||||
? tentativeVersion
|
||||
|
||||
Reference in New Issue
Block a user