First edit the run configuration for tests or for the application and select “Run Gradle task” as a build step:
Then add the task as task to execute for the application or for tests the testClasses
task:
Now whenever you run tests or the application Micronaut classes will be generated at compilation time.