Gradle custom JavaCompile task for annotation processing

I am working on a gradle plugin that registers a JavaCompile task that should trigger an annotation processing process.

Here is what I currently have

private fun Project.runConfiguration(variants: DomainObjectSet<out BaseVariant>) {
    variants.all { variant ->
        // Assert Shuttle annotation processor is present or throw exception
        val processor = ?: throw ShuttleCompilerNotFoundException()
        val packageName = variant.getPackageName()
        val task = tasks.register(
        ) {
            it.source = variant.getSourceFolders(SourceKind.JAVA).first()
            it.options.annotationProcessorPath = variant.annotationProcessorConfiguration
                    "-proc:only", "-implicit:none",
                    "-processor", processor


In an android project when I apply my plugin and run the task with gradle, Nothing happens so far. I even tried to throw and exception on the first line of my processor but still no success.

Am I missing something or doing something wrong? Also how can I tell the task that it should use ShuttleProcessor as an annotation processor.

I am working with kotlin and not Groovy .


I have found a solution to what wrong was happening. JavaCompile task has to be aware of where is the processor we use. So the missing piece was these lines

val classPath = variant.getCompileClasspath(null)

variant is gathered from Android build configurations
and my task’s configuration should incorporate these changes

classpath = classPath
options.annotationProcessorPath = classPath