13.1.2 Incremental Annotation Processing with Gradle

Micronaut supports Gradle incremental annotation processing which helps speed up builds by compiling only classes that have changed avoiding a full recompilation.

However, the support is disabled by default since Micronaut allows the definition of custom meta-annotations (to for example define custom AOP advice) that need to be configured for processing.

The following example demonstrates how to enable and configure incremental annotation processing for annotations you have defined under the com.example package:

Enabling Incremental Annotation Processing

  1. tasks.withType(JavaCompile) {
  2. options.compilerArgs = [
  3. '-Amicronaut.processing.incremental=true',
  4. '-Amicronaut.processing.annotations=com.example.*',
  5. ]
  6. }
If you do not enable processing for custom annotations you define these annotations will simple be ignored by Micronaut which may break your application.