mirror of
https://gitea.com/actions/setup-java.git
synced 2025-11-29 01:41:12 +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:
@@ -601,14 +601,29 @@ steps:
|
||||
## Java version file
|
||||
If the `java-version-file` input is specified, the action will extract the version from the file and install it.
|
||||
|
||||
Supported files are .java-version and .tool-versions.
|
||||
In .java-version file, only the version should be specified (e.g., 17.0.7).
|
||||
In .tool-versions file, java version should be preceded by the java keyword (e.g., java 17.0.7).
|
||||
The `.java-version` file recognizes all variants of the version description according to [jenv](https://github.com/jenv/jenv). Similarly, the `.tool-versions` file supports version specifications in accordance with [asdf](https://github.com/asdf-vm/asdf) standards, adhering to Semantic Versioning ([semver](https://semver.org/)).
|
||||
|
||||
If both java-version and java-version-file inputs are provided, the java-version input will be used.
|
||||
Supported files are `.java-version`, `.tool-versions` and `.sdkmanrc`.
|
||||
* In `.java-version` file, only the version should be specified (e.g., 17.0.7). The `.java-version` file recognizes all variants of the version description according to [jenv](https://github.com/jenv/jenv).
|
||||
* In `.tool-versions` file, java version should be preceded by the java keyword (e.g., java 17.0.7). The `.tool-versions` file supports version specifications in accordance with [asdf](https://github.com/asdf-vm/asdf) standards, adhering to Semantic Versioning ([semver](https://semver.org/)).
|
||||
* In `.sdkmanrc` file, java version should be preceded by the `java=` prefix (e.g., java=17.0.7-tem) and include the distribution. The `.sdkmanrc` file supports version specifications in accordance with [file format](https://sdkman.io/usage#env-command), see [Sdkman! documentation](https://sdkman.io/jdks) for more information.
|
||||
|
||||
Valid entry options:
|
||||
|
||||
If both `java-version` and `java-version-file` **inputs** are provided, the `java-version` input will be used.
|
||||
|
||||
**Example step using `Sdkman!`**:
|
||||
```yml
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version-file: '.sdkmanrc'
|
||||
distribution: 'temurin'
|
||||
```
|
||||
|
||||
**Example `.sdkmanrc`**:
|
||||
```
|
||||
java=17.0.7-tem
|
||||
```
|
||||
|
||||
Valid entry options (does not apply to `.sdkmanrc`):
|
||||
```
|
||||
major versions: 8, 11, 16, 17, 21
|
||||
more specific versions: 8.0.282+8, 8.0.232, 11.0, 11.0.4, 17.0
|
||||
@@ -619,4 +634,4 @@ LTS versions : temurin-21.0.5+11.0.LTS
|
||||
If the file contains multiple versions, only the first one will be recognized.
|
||||
|
||||
***NOTE***:
|
||||
For the tool-version file, ensure that you use standard semantic versioning (semver) formats, as non-standard formats (such as jetbrains-21b212.1) may not be parsed correctly. Additionally, for complex version strings containing multiple version-like segments (for example, java semeru-openj9-11.0.15+10_openj9-0.32.0), the extraction logic may incorrectly capture the last segment (0.32.0) instead of the main version (11.0.15+10).
|
||||
For the tool-version file, ensure that you use standard semantic versioning (semver) formats, as non-standard formats (such as jetbrains-21b212.1) may not be parsed correctly. Additionally, for complex version strings containing multiple version-like segments (for example, java semeru-openj9-11.0.15+10_openj9-0.32.0), the extraction logic may incorrectly capture the last segment (0.32.0) instead of the main version (11.0.15+10).
|
||||
|
||||
Reference in New Issue
Block a user