Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/log4j2Version-2.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Feb 24, 2023
2 parents e8b8554 + e9ddc1b commit aff4ecc
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 100 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {
junitDepVersion = "4.11.20120805.1225"
junitVersion = "4.13.2"
log4j2Version = "2.20.0"
springBootVersion = "2.7.8" // Spring Boot 3.0 requires Java 17 as a minimum version
springBootVersion = "2.7.9" // Spring Boot 3.0 requires Java 17 as a minimum version
systemRulesVersion = "1.19.0"
systemLambdaVersion = '1.2.1'
junit5Version = '5.9.2'
Expand Down
40 changes: 33 additions & 7 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10408,6 +10408,9 @@ Now our message texts are printed in Spanish:
Using the command line parameter `--locale`, one can also determine the language of the help output of your application.
The https://github.com/remkop/picocli/blob/main/picocli-examples[`picocli-examples`] module has examples with fully implemented, localized help output, coded both in https://github.com/remkop/picocli/blob/main/picocli-examples/src/main/java/picocli/examples/i18n/localecontrol/LocaleControl.java[Java] and https://github.com/remkop/picocli/tree/main/picocli-examples/src/main/kotlin/picocli/examples/kotlin/i18n/localecontrol/LocaleControl.kt[Kotlin].

=== JPMS Modules Internationalization
See <<Resource Bundles in JPMS Modules>>.

== Variable Interpolation

As of version 4.0, picocli supports variable interpolation (variable expansion) in annotation attributes as well as in text attributes of the programmatic API.
Expand Down Expand Up @@ -12447,27 +12450,50 @@ Applications that use Java 9's modules need to configure their module to allow p

Often applications want the annotated classes and fields to be **private**; there should be no need to make them part of the exported API of your module just to allow picocli to access them. The below settings make this possible.

Example `module-info.java`:
```
module com.yourorg.yourapp {
[source,java]
.Example `module-info.java`
----
module your.module {
requires info.picocli;

// Open this package for reflection to external frameworks.
opens your.package.using.picocli;

// or: limit access to picocli only
// (Applications with ResourceBundles: see CAUTION section below!)
opens other.package.using.picocli to info.picocli;
}
```
----
Note that neither package is `exported`, so other modules cannot accidentally compile against types in these packages.

Alternatively:
```
[source,java]
.Example compact `module-info.java`
----
// open all packages in the module to reflective access
open module com.yourorg.yourapp {
open module your.module {
requires info.picocli;
}
```
----

=== Resource Bundles in JPMS Modules
Applications using the `@Command(resourceBundle="XXX")` annotation may encounter an error saying "MissingResourceException: Can't find bundle for base name XXX".

The only way I could get this annotation to work in a modular JPMS application was by using `opens packageName` in the `module-info` instead of `opens packageName to info.picocli`.
For example:

[source,java]
.Example `module-info.java` for applications with ResourceBundles
----
module your.module {
requires info.picocli;
opens your.package.containing.resourceBundle;
//opens your.package.containing.resourceBundle to info.picocli; //MissingResourceException
}
----

Alternatively, a workaround is to call the programmatic API https://picocli.info/apidocs-all/info.picocli/picocli/CommandLine.html#setResourceBundle(java.util.ResourceBundle)[`CommandLine.setResourceBundle`] instead of using the `@Command(resourceBundle="XXX")` annotation.


== OSGi Bundle

Expand Down
Loading

0 comments on commit aff4ecc

Please sign in to comment.