Tested on Java LTS versions from 8 to 21.
Tested on Gradle versions from 6.7 to 8.12.
Usage:
plugins {
id 'name.remal.finalize-by-jacoco' version '1.0.5'
}
This plugin adds Lombok annotation processor to compileOnly
and annotationProcessor
configurations for every SourceSet
.
This is done via creating lombok
configuration and making compileOnly
and annotationProcessor
configurations extend it.
The plugin can be configured via lombok
extension:
lombok {
lombokVersion = '1.18.36' // Lombok version
}
The used Lombok version can also be configured via constraints. This is useful for tools that automatically update dependencies (like Renovate).
dependencies {
constraints {
lombok 'org.projectlombok:lombok:1.18.36'
}
}
This plugin supports the Lombok configuration system.
lombok.config
files are added to input files for all JavaCompile
tasks. So, if you change lombok.config
file(s), your code will be recompiled.
lombok.config
files are validated via validateLombokConfig
task. check
task is configured to execute validateLombokConfig
.
Supported rules can be found here.
The validation can be additionally configured:
lombok {
config {
validate {
disabledRules.add('AddGeneratedAnnotation') // Disable `AddGeneratedAnnotation` rule
}
}
}
lombok.config
file can be generated:
lombok {
config {
generate {
enabled = true // To enable generation
set('lombok.addLombokGeneratedAnnotation', true) // Add `lombok.addLombokGeneratedAnnotation = true` line
plus('lombok.copyableAnnotations', 'com.fasterxml.jackson.annotation.JsonProperty') // Add `lombok.copyableAnnotations += com.fasterxml.jackson.annotation.JsonProperty` line
minus('lombok.copyableAnnotations', 'com.fasterxml.jackson.annotation.JsonProperty') // Add `lombok.copyableAnnotations -= com.fasterxml.jackson.annotation.JsonProperty` line
clear('lombok.copyableAnnotations') // Add `clear lombok.copyableAnnotations` line
}
}
}
A delombok
task is created for every SourceSet
.
The javadoc
task is configured to process delomboked sources.
Delombok format con be configured this way:
lombok {
delombok {
format {
pretty = true // To use `--format=pretty`
indent = '2' // To use `--format=indent:2`
emptyLines = 'INDENT' // To use `--format=emptyLines:indent`
finalParams = 'SKIP' // To use `--format=finalParams:skip`
constructorProperties = 'GENERATE' // To use `--format=finalParams:generate`
suppressWarnings = 'SKIP' // To use `--format=suppressWarnings:skip`
generated = 'GENERATE' // To use `--format=generated:generate`
danceAroundIdeChecks = 'SKIP' // To use `--format=danceAroundIdeChecks:skip`
generateDelombokComment = 'GENERATE' // To use `--format=generateDelombokComment:generate`
javaLangAsFQN = 'SKIP' // To use `--format=javaLangAsFQN:skip`
}
}
}
lombok-mapstruct-binding
dependency is added to annotationProcessor
configuration for every SourceSet
.
The MapStruct annotation processor is always put before the Lombok annotation processor. It is done to prevent this MapStruct dependency ordering issue. The issue is marked as fixed, but it is still reproducible.
This logic is executed whether MapStruct is used in the project or not.
The Lombok annotation processor should always be before the Micronaut annotation processor to prevent issues like this. This plugin automatically applies a fix described here.
By default, the Lombok annotation processor is always put before any other annotation processors.
Exceptions:
- MapStruct - Lombok is always put after
If there is a compatibility issue and the Lombok annotation processor has to be after some processor (like MapStruct), please report it.
- Package name was changed from
name.remal.gradleplugins.lombok
toname.remal.gradle_plugins.lombok
.