Compare commits

...

3 Commits

Author SHA1 Message Date
Gerrit Grunwald 7beb7eb22c
Merge d3af3ec854 into 99b8673ff6 2024-03-17 15:40:39 +07:00
mahabaleshwars 99b8673ff6
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
2024-03-14 09:12:58 -05:00
Gerrit Grunwald d3af3ec854
Added the option jdk+crac
Because with Azul Zulu one can also use jdk+crac in combination with version 17 and 21, this was added to the README.md and advanced-usage.md.
This PR contains no code changes, just documentation.
2024-02-02 16:59:47 +01:00
5 changed files with 22 additions and 16 deletions

View File

@ -31,7 +31,7 @@ This action allows you to work with Java and Scala projects.
- `distribution`: _(required)_ Java [distribution](#supported-distributions).
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`, `jdk+crac`. Default value: `jdk`.
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.

11
dist/cleanup/index.js vendored
View File

@ -88355,15 +88355,16 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function getVersionFromFileContent(content, distributionName, versionFile) {
var _a, _b, _c, _d, _e;
let javaVersionRegExp;
if (versionFile == '.tool-versions') {
function getFileName(versionFile) {
return path_1.default.basename(versionFile);
}
const versionFileName = getFileName(versionFile);
if (versionFileName == '.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');
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)
? (_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
View File

@ -125729,15 +125729,16 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function getVersionFromFileContent(content, distributionName, versionFile) {
var _a, _b, _c, _d, _e;
let javaVersionRegExp;
if (versionFile == '.tool-versions') {
function getFileName(versionFile) {
return path_1.default.basename(versionFile);
}
const versionFileName = getFileName(versionFile);
if (versionFileName == '.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');
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)
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version

View File

@ -58,7 +58,7 @@ steps:
with:
distribution: 'zulu'
java-version: '21'
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx, jdk+crac) - defaults to jdk
- run: java -cp java HelloWorldApp
```

View File

@ -119,13 +119,17 @@ export function getVersionFromFileContent(
versionFile: string
): string | null {
let javaVersionRegExp: RegExp;
if (versionFile == '.tool-versions') {
function getFileName(versionFile: string) {
return path.basename(versionFile);
}
const versionFileName = getFileName(versionFile);
if (versionFileName == '.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');
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
const fileContent = content.match(javaVersionRegExp)?.groups?.version