Search code examples
build.gradlekotlinvert.xkapt

kapt plugin not working with gradle-script-kotlin


I want to move my vertx based project to https://github.com/sczyh30/vertx-blueprint-microservice.git template. The blueprint project uses annotations @vertxGen etc. to generate code during compilation.

I am using gradle-script-kotlin to build the project. I need to use kapt plugin to generate code as per annotations (via vertx ... codegen ). Unfortunately, am unable to correctly configure kapt plugin. Its giving following error:

w: [kapt] Sources output directory is not specified, skipping annotation processing

I would be delighted if someone could fix my gradle build file. Following are the kapt related snippets

import org.jetbrains.kotlin.gradle.plugin.* // kaptExtension
...
apply {
  plugin("kotlin-kapt")
}
...

fun Project.kapt(setup: KaptExtension.() -> Unit) = the<KaptExtension>().setup()

kapt {
        generateStubs = true

        javacOptions( closureOf<KaptJavacOptionsDelegate> {
                option("-proc:only")
                option("-processor", "io.vertx.codegen.CodeGenProcessor") // vertx processor here
                option("-AoutputDirectory", "${projectDir}/src/main")
                option("-Acodegen.output", "${projectDir}/src/main")
        } )

        // specify output of generated code
        arguments( closureOf<KaptAnnotationProcessorOptions> {
                arg("destinationDir", "${buildDir}/generated/source/kapt/main")
        } )
}
...
java {
...
        sourceSets.getByName("main").java.srcDirs("${project.buildDir}/generated/source/kapt/main")
}

Let me know for any other info/query. Thanks in advance.


Solution

  • I had to add following to the build.gradle.kts

    dependencies {
    ....
            kapt("io.vertx:vertx-codegen:$vertx_version:processor")
    ...
    }
    

    Still dont know why though. posting here to let others know.