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 = ShuttleProcessor::class.java.canonicalName ?: throw ShuttleCompilerNotFoundException()
val packageName = variant.getPackageName()
val task = tasks.register(
"generateShuttle${variant.name.capitalize()}Sources",
JavaCompile::class.java
) {
it.group = TASK_GROUP
it.source = variant.getSourceFolders(SourceKind.JAVA).first()
it.options.annotationProcessorPath = variant.annotationProcessorConfiguration
it.options.compilerArgs.addAll(listOf(
"-proc:only", "-implicit:none",
"-processor", processor
))
}
variant.registerJavaGeneratingTask(task.get())
}
}
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
.
Thanks.