I want to instruct my Kotlin annotation processor to change the output directory of the generated classes.
I want from my Gradle build script to change the kapt.kotlin.generated argument. I have tried the following to no avail.
Doesn't work, path doesn't change
kapt {
    arguments {
        arg("kapt.kotlin.generated", new File('path'))
    }
 }
Doesn't work, path doesn't change
kapt {
    javacOptions {
        option("kapt.kotlin.generated", new File('path'))
    }
 }
Doesn't work, NullPointerException when building
kapt {
    javacOptions {
        option("-Akapt.kotlin.generated", new File('path'))
    }
 }
Same results for all three when using a string path instead of a file.
I am at a loss, any help would be appreciated.
Use a different option name:
kapt{
    arguments {
        arg("kapt.kotlin.custom.generated",
                rootProject.file("foobar/build/generated/source/kaptKotlin/main").absolutePath)
    }
}
then retrieve the custom option in your annotation processor and use that as the target
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With