6

Is it possible to run kapt (kotlin annotation processing) in a maven based project?

If yes how do I integrate kapt in maven build system?

sockeqwe
  • 15,574
  • 24
  • 88
  • 144

1 Answers1

6

Since Kotlin 1.1.2 there is now support for both Gradle and Maven to run the KAPT plugins. This is documented in Using Kotlin annotation processing tool where it says to:

Add an execution of the kapt goal from kotlin-maven-plugin before compile:

<execution>
    <id>kapt</id>
    <goals>
        <goal>kapt</goal>
    </goals>
    <configuration>
        <sourceDirs>
            <sourceDir>src/main/kotlin</sourceDir>
            <sourceDir>src/main/java</sourceDir>
        </sourceDirs>
        <annotationProcessorPaths>
            <!-- Specify your annotation processors here. -->
            <annotationProcessorPath>
                <groupId>com.google.dagger</groupId>
                <artifactId>dagger-compiler</artifactId>
                <version>2.9</version>
            </annotationProcessorPath>
        </annotationProcessorPaths>
    </configuration>
</execution>
Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
  • 1
    Is this still true? There seem to be `kapt` within `kotlin-maven-plugin` - described here: https://kotlinlang.org/docs/reference/kapt.html – Vojtěch May 23 '17 at 12:14