Annotation Processor in IntelliJ and Gradle

前端 未结 4 1519
终归单人心
终归单人心 2020-12-17 09:18

tl;dr: I cannot configure IntelliJ to generate the java files in the same directory as gradle

I have a small project which uses the immutables annot

4条回答
  •  醉话见心
    2020-12-17 09:33

    Now https://github.com/tbroyer/gradle-apt-plugin states:

    The goal of this plugin was to eventually no longer be needed, being superseded by built-in features. This is becoming a reality with Gradle 5.2 and IntelliJ IDEA 2019.1.

    So:

    dependencies {
      compile("com.google.dagger:dagger:2.18")
      annotationProcessor("com.google.dagger:dagger-compiler:2.18")
    
      compileOnly("com.google.auto.factory:auto-factory:1.0-beta6")
      annotationProcessor("com.google.auto.factory:auto-factory:1.0-beta6")
    
      compileOnly("org.immutables:value-annotations:2.7.1")
      annotationProcessor("org.immutables:value:2.7.1")
    }
    

    compileOnly is necessary if you use annotations, compile if you use classes, annotationProcessor introduced in Gradle 4.6.

    To enable processing specific compile task:

    compileJava {
        options.annotationProcessorPath = configurations.annotationProcessor
    }
    

    To disable:

      compileTestJava {
          options.compilerArgs += '-proc:none'
      }
    

提交回复
热议问题