mirror of
https://github.com/actions/setup-java.git
synced 2025-06-28 20:14:14 +00:00
Added .tool-versions file support (#606)
* added support for tool version file * testing with one regex * working regex * Checked for the file extension * added e2e checks for tool version * removed error warning * updated regex to support early version * updated regex for early version support * updated regex for early version * updated regex to accept early versions * added coreinfo to analyze * updated the regex * updated regex * new regex for early version * updated regex to match the new version file format * new regex * changed the regex * redex updated * used java version regex * regex updated * regex modified * regex updated * regex updated * regex updated * updated regex to support early versions * Regex updated to support all java versions * Documentation updated to add tool version description * Documentation updated for the tool version file * update the advanced doc and readme file to specify tool version changes
This commit is contained in:
parent
80ae3c2885
commit
5896cecc08
7 changed files with 75 additions and 17 deletions
14
src/util.ts
14
src/util.ts
|
@ -115,9 +115,19 @@ export function isCacheFeatureAvailable(): boolean {
|
|||
|
||||
export function getVersionFromFileContent(
|
||||
content: string,
|
||||
distributionName: string
|
||||
distributionName: string,
|
||||
versionFile: string
|
||||
): string | null {
|
||||
const javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
let javaVersionRegExp: RegExp;
|
||||
if (versionFile == '.tool-versions') {
|
||||
javaVersionRegExp =
|
||||
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
|
||||
} else if (versionFile == '.java-version') {
|
||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||
} else {
|
||||
throw new Error('Invalid version file');
|
||||
}
|
||||
|
||||
const fileContent = content.match(javaVersionRegExp)?.groups?.version
|
||||
? (content.match(javaVersionRegExp)?.groups?.version as string)
|
||||
: '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue