I totally exhausted with Dagger 2 in non-Android app (IDE is IntelliJ IDEA).
build.gradle
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "net.ltgt.gradle:gradle-apt-plugin:0.9"
    }
}
apply plugin: 'java'
apply plugin: 'net.ltgt.apt'
dependencies {
    compile 'com.google.dagger:dagger:2.8'
    apt 'com.google.dagger:dagger-compiler:2.8'
    compileOnly 'javax.annotation:jsr250-api:1.0'
}
Component
@Component(modules = {MyModule.class}) public interface MyComponent {}
Module
@Module class MyModule {}
Main
DaggerMyComponent component = DaggerMyComponent.builder().build();
Compiler says
cannot find symbol DaggerMyComponent
Absolutely have no more ideas what could be wrong :(
By the way, if I run gradlew clean build --refresh-dependencies, there is no error, everything fine!
But as only I use 'Rebuild project' in IDE - error again. Possibly IDEA bug (time to go back to Eclipse)?
And yes, I have added directory with generated classes as a content root, so IDE can see DaggerMyComponent.
 
    
 
     
    