I want to use Dagger
in IntelliJ
but I can't use it. Dagger uses an annotation processor and I guess IntelliJ doesn't know about the annotation processor.
You can see the generated java file, it's generated by the Dagger2
compiler, but my java source can't find them. Even if I set build.gradle
to connect between my java file and the generated java file.
This is my whole source project file.
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
def generatedSources = "$buildDir/generated/src"
def generatedOutputDir = file("$generatedSources")
compileJava {
doFirst {
generatedOutputDir.exists() || generatedOutputDir.mkdirs()
options.compilerArgs = [
'-s', "${generatedSources}"
]
}
}
sourceSets {
main {
java {
srcDirs += generatedOutputDir
}
}
}
dependencies {
compile "com.google.dagger:dagger:2.0"
compile "com.google.dagger:dagger-compiler:2.0"
compile "com.squareup:otto:1.3.8"
compile 'io.reactivex:rxjava:1.0.13'
compile "org.glassfish:javax.annotation:10.0-b28"
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:1.9.5"
}
compileJava.dependsOn clean