Maven支持kapt吗? [英] Is kapt supported in maven?

查看:215
本文介绍了Maven支持kapt吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在基于Maven的项目中运行kapt(kotlin注释处理)?

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

如果可以,我如何将kapt集成到Maven构建系统中?

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

推荐答案

自Kotlin 1.1.2起,现在已经支持Gradle和Maven来运行KAPT插件. 使用Kotlin注释处理工具中对此进行了说明,表示:

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:

在编译之前从kotlin-maven-plugin中添加对kapt目标的执行:

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>

这篇关于Maven支持kapt吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆