Using annotation processor in version 4.6


(Jernej Klancic) #1

I was reading that the newest gradle version (version 4.6) has now annotation processor support. I updated my gradle wrapper to 4.6 and used this new feature. It does create the dagger-related files, but then fails to use them in my project. Somehow I get:

> Task :compileJava FAILED
.../src/main/java/xyz/blackmonster/resume/app/Application.java:17: error: cannot find symbol
import xyz.blackmonster.resume.config.DaggerBeanComponent;
                                     ^
  symbol:   class DaggerBeanComponent
  location: package xyz.blackmonster.resume.config
1 error

Here is my gradle.build file:

plugins {
    id "java"
    id "idea"
}

group 'xyz.blackmonster'
version '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

ext {
    dropwizardVersion = "1.3.0"
    mysqlConnectorVersion = "8.0.9-rc"
    daggerVersion = "2.15"
    mockitoVersion = "2.16.0"
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'io.dropwizard', name: 'dropwizard-core', version: dropwizardVersion
    compile group: 'io.dropwizard', name: 'dropwizard-jdbi3', version: dropwizardVersion
    compile group: 'io.dropwizard', name: 'dropwizard-auth', version: dropwizardVersion
    compile group: 'io.dropwizard', name: 'dropwizard-metrics-graphite', version: dropwizardVersion
    compile group: 'mysql', name: 'mysql-connector-java', version: mysqlConnectorVersion
    annotationProcessor group: 'com.google.dagger', name: 'dagger-compiler', version: daggerVersion
    implementation group: 'com.google.dagger', name: 'dagger', version: daggerVersion
    testCompile group: 'io.dropwizard', name: 'dropwizard-testing', version: dropwizardVersion
    testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
}

I am following the release notes, but for some reason it does not work. Can someone tell me what am I doing wrong. Why is the generated Dagger file not being picked up on compile time, even though the Dagger classes are being generated properly in build/classes/java/main?

Here is the full project on github.

I would appreciate any help, because I am trying to resolve this for the past 4 days and I am not making any progress.


(Stefan Oehme) #2

Your imports are wrong. Should be xyz.blackmonster.resume.config.bean.DaggerBeanComponent.


(Jernej Klancic) #3

@st_oehme you are right! Thanks for pointing that out. I did not see this. Now it builds normally.