5

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.

  1. Doesn't work, path doesn't change

    kapt { arguments { arg("kapt.kotlin.generated", new File('path')) } }

  2. Doesn't work, path doesn't change

    kapt { javacOptions { option("kapt.kotlin.generated", new File('path')) } }

  3. 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.

iFanie
  • 916
  • 8
  • 10

1 Answers1

1

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