tentackle-check:bundles

Full name:

org.tentackle:tentackle-check-maven-plugin:25.20.0.0:bundles

Description:

Verifies all bundle getString() invocations.

Finds all invocations of <reference>.getString(<key>), where <key> is a compile-time constant, i.e. a string literal, a constant variable such as static final String KEY = "foo", or a concatenation of those, and <reference> is:

  • a bundle classname, e.g. BlahBundle.getString("foo") checked against BlahBundle properties. The class is resolved via a single-type import or the package of the invoking class.
  • a method that refers to a bundle with the same name as the class containing the method invocation, e.g. getBundle().getString("foo") in class Blah corresponds to the key "foo" in Blah.properties.
  • a variable or constant: same as method, i.e. the bundle name is that of the containing class, e.g. resources.getString("foo").
Nested classes refer to the bundle of their outermost class. Each referenced bundle must be registered via an annotation such as @Bundle or @FxControllerService (see org.tentackle.common.BundleSupport ), and is loaded for each configured locale. Furthermore, the key sets of each referenced bundle are compared across all locales.

The sources are attributed by the compiler, so only invocations that really refer to a bundle count: a static getString(String) of a bundle class, i.e. annotated with @Bundle or another annotation that registers bundles, or one invoked on a java.util.ResourceBundle. Other invocations, such as ResultSet.getString("column"), are ignored. So are invocations that refer to the bundle of a class annotated with org.tentackle.common.NoBundle, i.e. a class that looks like a bundle but is not registered as one. If the invoked method or the type of the reference cannot be determined, for example, due to compile errors, the invocation is checked nevertheless and logged as a warning.

The following cases are not covered by this mojo:

  • All non-constant keys, e.g., getBundle().getString(text) as often found in enums. They are logged as warnings and need explicit tests. The warnings can be suppressed by annotating the invoking code or any enclosing declaration with @SuppressWarnings("bundle").
  • PdoBundles, i.e., translations for @Singular, @Plural. See PdoUtilitiesTest.
  • ValidationBundles, i.e., translations in validators, are covered by the mojo tentackle-check:validations.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile.
  • The goal is thread-safe and supports parallel builds.
  • Binds by default to the lifecycle phase: process-classes.

Required Parameters

Name Type Since Description
<sourceDir> File - Directory holding the sources to be processed.
Defaults to all Java sources of the current project. Use filesets to check only a subset or to exclude files.
Default: ${project.build.sourceDirectory}
User Property: tentackle.sourceDir

Optional Parameters

Name Type Since Description
<charset> String - The encoding to read and write files.
Applied JVM-wide, see org.tentackle.maven.AbstractTentackleMojo.determineEncoding() .
Default: ${project.build.sourceEncoding}
<compilerArgs> List<String> - Arguments to be passed to the compiler.
(see maven-compiler-plugin)

Unless one of them is a -proc: option, -proc:only is added.

<compilerArgument> String - A single argument to be passed to the compiler as is.
(see maven-compiler-plugin)
<encoding> String - The source file encoding.
If not set, the compiler's default is used.
Default: ${project.build.sourceEncoding}
<filesets> List<FileSet> - The list of file sets.
If set, they are processed instead of the whole source directory. A file set without a directory defaults to the source directory.
<jdkToolchain> Map<String,String> - Toolchain for invocation of external tools.
Explicitly specifies the "jdk" toolchain for this plugin only. Overrides the toolchain selected by the maven-toolchain-plugin, if any.

Example:

  <jdkToolchain>
    <version>25</version>
  </jdkToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jdkToolchain></jdkToolchain>
<locales> String - The locales to check the bundles and validation messages against.
A comma, semicolon or whitespace separated list. Both the en_US and the en-US notation are accepted. Defaults to the build's default locale.

The fallback locale should come first, because the bundles of the other locales are compared against it.

<minLogLevel> String - The minimum logging java.util.logging.Level to redirect java.util logging to the maven logger.
Any name or value accepted by java.util.logging.Level.parse(java.lang.String) .
Default: WARNING
<scriptingLanguage> String - The default scripting language of the validator scripts.
Required if scripts use the shorthand {...} instead of naming their language explicitly, such as #!groovy{...}. The language's provider must be added as a plugin dependency.
<showCompileOutput> boolean - Shows the compiler diagnostics in the build log.
Errors reported by the annotation processors are always shown.
Default: ${tentackle.showCompileOutput}
<skip> Boolean - Skips processing.
If not set, defaults to true if packaging is "pom" and the execution is recursive (see org.tentackle.maven.AbstractTentackleMojo.isSkippedByDefault() ).
<skipTests> boolean - Skips the checks.
Bound to skipTests, so -DskipTests skips them together with the unit tests.
Default: ${skipTests}
<verbosity> String - The verbosity.
One of "default", "info" or "debug". Other values are treated as "default".
If not set, debug is turned on by Maven's global debug flag (see command line switch -X).
Default: ${tentackle.verbosity}

Parameter Details

<charset>

The encoding to read and write files.
Applied JVM-wide, see org.tentackle.maven.AbstractTentackleMojo.determineEncoding() .
  • Type: java.lang.String
  • Required: No
  • Default: ${project.build.sourceEncoding}

<compilerArgs>

Arguments to be passed to the compiler.
(see maven-compiler-plugin)

Unless one of them is a -proc: option, -proc:only is added.

  • Type: java.util.List<java.lang.String>
  • Required: No

<compilerArgument>

A single argument to be passed to the compiler as is.
(see maven-compiler-plugin)
  • Type: java.lang.String
  • Required: No

<encoding>

The source file encoding.
If not set, the compiler's default is used.
  • Type: java.lang.String
  • Required: No
  • Default: ${project.build.sourceEncoding}

<filesets>

The list of file sets.
If set, they are processed instead of the whole source directory. A file set without a directory defaults to the source directory.
  • Type: java.util.List<org.apache.maven.shared.model.fileset.FileSet>
  • Required: No

<jdkToolchain>

Toolchain for invocation of external tools.
Explicitly specifies the "jdk" toolchain for this plugin only. Overrides the toolchain selected by the maven-toolchain-plugin, if any.

Example:

  <jdkToolchain>
    <version>25</version>
  </jdkToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jdkToolchain></jdkToolchain>
  • Type: java.util.Map<java.lang.String, java.lang.String>
  • Required: No

<locales>

The locales to check the bundles and validation messages against.
A comma, semicolon or whitespace separated list. Both the en_US and the en-US notation are accepted. Defaults to the build's default locale.

The fallback locale should come first, because the bundles of the other locales are compared against it.

  • Type: java.lang.String
  • Required: No

<minLogLevel>

The minimum logging java.util.logging.Level to redirect java.util logging to the maven logger.
Any name or value accepted by java.util.logging.Level.parse(java.lang.String) .
  • Type: java.lang.String
  • Required: No
  • Default: WARNING

<scriptingLanguage>

The default scripting language of the validator scripts.
Required if scripts use the shorthand {...} instead of naming their language explicitly, such as #!groovy{...}. The language's provider must be added as a plugin dependency.
  • Type: java.lang.String
  • Required: No

<showCompileOutput>

Shows the compiler diagnostics in the build log.
Errors reported by the annotation processors are always shown.
  • Type: boolean
  • Required: No
  • Default: ${tentackle.showCompileOutput}

<skip>

Skips processing.
If not set, defaults to true if packaging is "pom" and the execution is recursive (see org.tentackle.maven.AbstractTentackleMojo.isSkippedByDefault() ).
  • Type: java.lang.Boolean
  • Required: No

<skipTests>

Skips the checks.
Bound to skipTests, so -DskipTests skips them together with the unit tests.
  • Type: boolean
  • Required: No
  • Default: ${skipTests}

<sourceDir>

Directory holding the sources to be processed.
Defaults to all Java sources of the current project. Use filesets to check only a subset or to exclude files.
  • Type: java.io.File
  • Required: Yes
  • User Property: tentackle.sourceDir
  • Default: ${project.build.sourceDirectory}

<verbosity>

The verbosity.
One of "default", "info" or "debug". Other values are treated as "default".
If not set, debug is turned on by Maven's global debug flag (see command line switch -X).
  • Type: java.lang.String
  • Required: No
  • Default: ${tentackle.verbosity}