How do I configure IntelliJ/gradle to use dagger 2.0

后端 未结 8 2086
野的像风
野的像风 2020-12-28 16:01

I have a gradle project and I want to use dagger 2.0 in it. I don\'t know how to configure IntelliJ and gradle to generate files and let IntelliJ find them?

My build

8条回答
  •  有刺的猬
    2020-12-28 16:23

    I finished up with the following solution (and it seems to be the simplest one from all the sent answers):

    apply plugin: 'java'
    apply plugin: 'idea'
    
    def generatedMain = new File(buildDir, "generated/main")
    
    compileJava {
        doFirst {
            generatedMain.mkdirs()
        }
        options.compilerArgs += ['-s', generatedMain]
    }
    idea.module.sourceDirs += generatedMain
    
    dependencies {
        compileOnly 'com.google.dagger:dagger-compiler:2.8'
        compile 'com.google.dagger:dagger:2.8'
    }
    

提交回复
热议问题