feat(java): Add .sdkmanrc for Java (#4888)

* Add `.sdkmanrc` for Java

* Update config-schema.json, Add `.sdkmanrc` file for Java

* Update doc
This commit is contained in:
iuhoay 2023-02-11 21:06:21 +08:00 committed by GitHub
parent e6c5571fc9
commit 07c2298965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 13 deletions

View File

@ -809,7 +809,8 @@
".java-version",
"deps.edn",
"project.clj",
"build.boot"
"build.boot",
".sdkmanrc"
],
"detect_folders": [],
"disabled": false,
@ -3701,7 +3702,8 @@
".java-version",
"deps.edn",
"project.clj",
"build.boot"
"build.boot",
".sdkmanrc"
],
"type": "array",
"items": {

View File

@ -2208,21 +2208,21 @@ disabled = false
The `java` module shows the currently installed version of [Java](https://www.oracle.com/java/).
By default the module will be shown if any of the following conditions are met:
- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `deps.edn`, `project.clj`, or `build.boot` file
- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `deps.edn`, `project.clj`, `build.boot`, or `.sdkmanrc` file
- The current directory contains a file with the `.java`, `.class`, `.gradle`, `.jar`, `.clj`, or `.cljc` extension
### Options
| Option | Default | Description |
| ------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `'via [${symbol}(${version} )]($style)'` | The format for the module. |
| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `['java', 'class', 'gradle', 'jar', 'cljs', 'cljc']` | Which extensions should trigger this module. |
| `detect_files` | `['pom.xml', 'build.gradle.kts', 'build.sbt', '.java-version', 'deps.edn', 'project.clj', 'build.boot']` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. |
| `symbol` | `'☕ '` | A format string representing the symbol of Java |
| `style` | `'red dimmed'` | The style for the module. |
| `disabled` | `false` | Disables the `java` module. |
| Option | Default | Description |
| ------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `'via [${symbol}(${version} )]($style)'` | The format for the module. |
| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `['java', 'class', 'gradle', 'jar', 'cljs', 'cljc']` | Which extensions should trigger this module. |
| `detect_files` | `['pom.xml', 'build.gradle.kts', 'build.sbt', '.java-version', 'deps.edn', 'project.clj', 'build.boot', '.sdkmanrc']` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. |
| `symbol` | `'☕ '` | A format string representing the symbol of Java |
| `style` | `'red dimmed'` | The style for the module. |
| `disabled` | `false` | Disables the `java` module. |
### Variables

View File

@ -35,6 +35,7 @@ impl<'a> Default for JavaConfig<'a> {
"deps.edn",
"project.clj",
"build.boot",
".sdkmanrc",
],
detect_folders: vec![],
}

View File

@ -245,6 +245,16 @@ mod tests {
dir.close()
}
#[test]
fn folder_with_sdkman_file() -> io::Result<()> {
let dir = tempfile::tempdir()?;
File::create(dir.path().join(".sdkmanrc"))?.sync_all()?;
let actual = ModuleRenderer::new("java").path(dir.path()).collect();
let expected = Some(format!("via {}", Color::Red.dimmed().paint("☕ v13.0.2 ")));
assert_eq!(expected, actual);
dir.close()
}
#[test]
fn folder_with_gradle_kotlin_build_file() -> io::Result<()> {
let dir = tempfile::tempdir()?;