Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is kapt supported in maven?

Tags:

maven

kotlin

kapt

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?

like image 685
sockeqwe Avatar asked Sep 16 '16 12:09

sockeqwe


People also ask

Is kapt deprecated?

app: Original kapt is deprecated.

What is kapt used for?

What is KAPT used for? The answer to this is straight, it is used for annotation processing in Kotlin.

What is kotlin annotation processor?

KSP is a powerful tool that helps developers to write light-weight compiler plugins and annotation processors while maintaining a Kotlin-friendly API. Using KSP can help developers and tech leaders to create libraries that help them achieve more productivity by generating files and boilerplate code.


1 Answers

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>
like image 183
5 revs Avatar answered Sep 23 '22 07:09

5 revs