13.3.1 Kotlin, Kapt and IntelliJ

As of this writing, IntelliJ’s built-in compiler does not directly support Kapt and annotation processing. You must instead configure Intellij to run Gradle (or Maven) compilation as a build step before running your tests or application class.

First, edit the run configuration for tests or for the application and select “Run Gradle task” as a build step:

Intellij Settings

Then add the classes task as task to execute for the application or for tests the testClasses task:

Intellij Settings

Now when you run tests or start the application, Micronaut will generate classes at compile time.

Alternatively, you can delegate IntelliJ build/run actions to Gradle completely:

delegatetogradle