Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle deprecated annotation processor warnings for lombok

After upgrading to gradle 4.7, my previously warning-free build now emits this warning:

The following annotation processors were detected on the compile classpath: 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor' and 'lombok.launch.AnnotationProcessorHider$ClaimingProcessor'. Detecting annotation processors on the compile classpath is deprecated and Gradle 5.0 will ignore them. Please add them to the annotation processor path instead. If you did not intend to use annotation processors, you can use the '-proc:none' compiler argument to ignore them.

It seems that annotation processors are deprecated and gradle version 5.0 will not support annotation processors.

My project uses lombok, which requries annotation processors, so using -proc:none is not an option. Neither is stopping using Gradle when verison 5.0 is released.

How do I:

  • stop the warnings, and
  • ensure my project will continue to build with future Gradle releases?
like image 391
Bohemian Avatar asked May 06 '18 17:05

Bohemian


2 Answers

Change the lombok dependency type from compile to annotationProcessor, so your dependencies section in your build.gradle file should look like:

dependencies {
    compileOnly('org.projectlombok:lombok:1.16.20')
    annotationProcessor 'org.projectlombok:lombok:1.16.20'
    // compile 'org.projectlombok:lombok:1.16.20' <-- this no longer works!
    // other dependencies...
}
like image 58
Bohemian Avatar answered Nov 14 '22 02:11

Bohemian


If your project contains tests then you'll need the following configuration to completely rid yourself of the gradle warning:

dependencies {
  compileOnly "org.projectlombok:lombok:1.18.2"
  testCompileOnly "org.projectlombok:lombok:1.18.2"
  annotationProcessor "org.projectlombok:lombok:1.18.2"
  testAnnotationProcessor "org.projectlombok:lombok:1.18.2"
}

Adjust the lombok version to suit.

like image 29
Andy Brown Avatar answered Nov 14 '22 02:11

Andy Brown