mirror of
https://github.com/actions/setup-java
synced 2024-12-22 05:02:41 +00:00
Patch for java version file (#610)
* patch to extract file from other location * patch to extract filename from other directories * removed code failing checks * changed the validation for .java-version type
This commit is contained in:
parent
5896cecc08
commit
99b8673ff6
3 changed files with 20 additions and 14 deletions
11
dist/cleanup/index.js
vendored
11
dist/cleanup/index.js
vendored
|
@ -88355,15 +88355,16 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
function getVersionFromFileContent(content, distributionName, versionFile) {
|
function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||||
var _a, _b, _c, _d, _e;
|
var _a, _b, _c, _d, _e;
|
||||||
let javaVersionRegExp;
|
let javaVersionRegExp;
|
||||||
if (versionFile == '.tool-versions') {
|
function getFileName(versionFile) {
|
||||||
|
return path_1.default.basename(versionFile);
|
||||||
|
}
|
||||||
|
const versionFileName = getFileName(versionFile);
|
||||||
|
if (versionFileName == '.tool-versions') {
|
||||||
javaVersionRegExp =
|
javaVersionRegExp =
|
||||||
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
||||||
}
|
}
|
||||||
else if (versionFile == '.java-version') {
|
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
throw new Error('Invalid version file');
|
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 fileContent = ((_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
|
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||||
|
|
11
dist/setup/index.js
vendored
11
dist/setup/index.js
vendored
|
@ -125729,15 +125729,16 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
function getVersionFromFileContent(content, distributionName, versionFile) {
|
function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||||
var _a, _b, _c, _d, _e;
|
var _a, _b, _c, _d, _e;
|
||||||
let javaVersionRegExp;
|
let javaVersionRegExp;
|
||||||
if (versionFile == '.tool-versions') {
|
function getFileName(versionFile) {
|
||||||
|
return path_1.default.basename(versionFile);
|
||||||
|
}
|
||||||
|
const versionFileName = getFileName(versionFile);
|
||||||
|
if (versionFileName == '.tool-versions') {
|
||||||
javaVersionRegExp =
|
javaVersionRegExp =
|
||||||
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
||||||
}
|
}
|
||||||
else if (versionFile == '.java-version') {
|
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
throw new Error('Invalid version file');
|
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 fileContent = ((_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
|
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||||
|
|
12
src/util.ts
12
src/util.ts
|
@ -119,13 +119,17 @@ export function getVersionFromFileContent(
|
||||||
versionFile: string
|
versionFile: string
|
||||||
): string | null {
|
): string | null {
|
||||||
let javaVersionRegExp: RegExp;
|
let javaVersionRegExp: RegExp;
|
||||||
if (versionFile == '.tool-versions') {
|
|
||||||
|
function getFileName(versionFile: string) {
|
||||||
|
return path.basename(versionFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionFileName = getFileName(versionFile);
|
||||||
|
if (versionFileName == '.tool-versions') {
|
||||||
javaVersionRegExp =
|
javaVersionRegExp =
|
||||||
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
||||||
} else if (versionFile == '.java-version') {
|
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid version file');
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileContent = content.match(javaVersionRegExp)?.groups?.version
|
const fileContent = content.match(javaVersionRegExp)?.groups?.version
|
||||||
|
|
Loading…
Reference in a new issue