José Andias
José Andias

Reputation: 1974

How to find dependency providing annotation processor

I am running a build with latest Gradle version (v4.6) in a project with a lot of classpath dependencies. I get:

Putting annotation processors on the compile classpath has been deprecated and is scheduled to be removed in Gradle 5.0. Please add them to the processor path instead.

How can I find the offending dependency/ies (in a reasonable way)?

Upvotes: 1

Views: 796

Answers (1)

José Andias
José Andias

Reputation: 1974

The best way I found so far is to add-hoc the following code myself to the build script:

tasks.withType(JavaCompile) {
    doFirst {
        effectiveAnnotationProcessorPath.each { maybeJar ->
            if (maybeJar.file) {
                println "Doing: " + maybeJar.name
                zipTree(maybeJar).matching {
                    include 'META-INF/services/javax.annotation.processing.Processor'
                } each {
                    processorConfigFile -> 
                    println "Annotation processor(s) found in $maybeJar.name:"
                    println processorConfigFile.filterLine { it =~ /^(?!#)/ }
                }
            }
        }
    }
}

(based on this Gradle forum answer)

Upvotes: 2

Related Questions