Is there any way of making IntelliJ IDEA recognizing Dagger 2 generated classes in a Java project?

前端 未结 8 935
抹茶落季
抹茶落季 2020-12-14 16:21

Context

I have started a personal project in java with Gradle as the build system and I want to use Dagger 2 as a DI. The main reason o

8条回答
  •  [愿得一人]
    2020-12-14 16:39

    I'm using version 2017.3.3 of IntelliJ IDEA, version 0.14 of the net.ltgt.apt plugin and version 2.14.1 of Dagger and as well as applying the idea plugin in the build.gradle file (as in Pelocho's answer) I found I also had to tell IntelliJ where it can find the sources generated by Dagger, as follows:

    apply plugin: 'idea'
    idea {
        module {
            sourceDirs += file("$buildDir/generated/source/apt/main")
            testSourceDirs += file("$buildDir/generated/source/apt/test")
        }
    }
    

提交回复
热议问题