Annotation processor not found

I have a Gradle 5.3.1 project that needs to run a codegen task prior to building the rest of the project, including the generated code.

I have the codegen processor declared in a dependencies block like so:

def vertxVersion = "3.6.3"
dependencies {
    // ...some dependencies
    annotationProcessor "io.vertx:vertx-codegen:$vertxVersion"
   // ...more dependencies
}

…and I have the codegen task setup like so:

task generatePolyglotApis(type: JavaCompile) {
    group 'build'
    description 'Generates Vertx js and rxjava shims'
    source = sourceSets.main.java
    classpath = configurations.compile + configurations.compileOnly + configurations.annotationProcessor
    options.debugOptions.debugLevel = "source,lines,vars"
    options.compilerArgs = [
            "-proc:only",
            "-processor", "io.vertx.codegen.CodeGenProcessor",
            "-Acodegen.output=${projectDir}/src/main"
    ]
    destinationDir = file("${buildDir}/generated-sources/vertx")
}

…and I can’t get the codegen task to work. I’ve read through every topic in this forum referencing annotation processors and haven’t found anything that helps so far. It’s always failing with Annotation processor 'io.vertx.codegen.CodeGenProcessor' not found.

What am I missing?

I found the problem. In the generatePolyglotApis task, I need to move the configurations.annotationProcessor collection to a different option:

    options.annotationProcessorPath = configurations.annotationProcessor

…then, in the compileJava task configuration, I need to disable processors:

compileLava {
    dependsOn generatePolyglotApis
    options.compilerArgs += '-proc:none'
}

…this got me back on track

1 Like