NEW in lombok 1.14: You can create lombok.config
files in any directory and put configuration directives in it. These apply to all source files in this directory and all child directories.
The configuration system is particularly useful for configurable aspects of lombok which tend to be the same across an entire project, such as the name of your log variable. The configuration system can also be used to tell lombok to flag any usage of some lombok feature you don't like as a warning or even an error.
Usually, a user of lombok puts a lombok.config
file with their preferences in a workspace or project root directory, with the special config.stopBubbling = true
key to tell lombok this is your root directory. You can then create lombok.config
files in any subdirectories (generally representing projects or source packages) with different settings.
An up to date list of all configuration keys supported by your version of lombok can be generated by running:
java -jar lombok.jar config -g --verbose
lombok.config
file.
A sample of available configuration options (see the feature pages of the lombok features for their related config keys, as well as java -jar lombok.jar config -g
for the complete list):
lombok.accessors.chain
true
, generated setters will 'chain' by default (They will return this
instead of having a void
return type).lombok.accessors.fluent
true
, generated setters and getters will simply be named the same as the field name, without a get
or set
prefix.lombok.anyConstructor.suppressConstructorProperties
true
, lombok will not generate a @java.beans.ConstructorProperties
annotation when generating constructors. This is particularly useful for GWT and Android development.lombok.log.fieldName
log
).lombok.(featureName).flagUsage
warning
or error
. Some examples of values for (featureName) are: "experimental
" (flags use of any of the experimental features), "builder
", "sneakyThrows
", or "extensionMethod
".
Configuration files are hierarchical: Any configuration setting applies to all source files in that directory, and all source files in subdirectories, but configuration settings closer to the source file take precedence. For example, if you have in /Users/me/projects/lombok.config
the following:
lombok.log.fieldName = foobar
/Users/me/projects/MyProject/lombok.config
you have:
lombok.log.fieldName = xyzzy
@Log
annotations will use foobar
instead of the default log
as a field name to generate in all your projects,
except for your project in /Users/me/projects/MyProject
, where xyzzy
is used instead.
To restore a configuration key set by a parent config file back to the default, the clear
option can be used. For example, if a parent configuration file has configured all use of val
to emit a warning, you can turn off the warnings for a subdirectory by including in it a lombok.config
file with:
clear lombok.val.flagUsage
Some configuration keys take lists. For lists, use +=
to add an entry. You can remove a single item from the list (useful to undo a parent configuration file's setting) with -=
. For example:
lombok.accessors.prefix += m_
Comments can be included in lombok.config
files; any line that starts with #
is considered a comment.
To stop lombok from looking at parent directories for more configuration files, the special key:
config.stopBubbling = true
Lombok normally adds @javax.annotation.Generated
annotations to all generated nodes where possible. You can stop this with:
lombok.addGeneratedAnnotation = false
Lombok can add the @SuppressFBWarnings
annotation which is useful if you want to run FindBugs on your class files. To enable this feature, make sure findbugs is on the classpath when you compile, and add the following config key:
lombok.extern.findbugs.addSuppressFBWarnings = true
lombok.fieldDefaults.defaultPrivate = true
lombok.fieldDefaults.defaultFinal = true
@FieldDefaults
documentation for more.