Gradle deprecated annotation processor warnings for lombok

后端 未结 3 1875
悲&欢浪女
悲&欢浪女 2021-02-03 22:06

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

The following annotation processors were detected on the compile c

相关标签:
3条回答
  • 2021-02-03 22:18

    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...
    }
    
    0 讨论(0)
  • 2021-02-03 22:21

    Gradle added annotationProcessor in 4.6 and Lombok is an annotation processor even though their documentation is not really clear about this when using Gradle they are also aware of it as they recommend it when using Android Studio. So short answer is to use:

    dependencies {
        compileOnly('org.projectlombok:lombok:1.18.0')
        annotationProcessor('org.projectlombok:lombok:1.18.0')
    }
    
    0 讨论(0)
  • 2021-02-03 22:26

    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.

    0 讨论(0)
提交回复
热议问题