kapt是否支持kapt?(Is kapt supported in maven?)

编程入门 行业动态 更新时间:2024-10-17 05:01:52
kapt是否支持kapt?(Is kapt supported in maven?)

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

如果是,我如何在maven构建系统中集成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?

最满意答案

从Kotlin 1.1.2开始,现在支持Gradle和Maven运行KAPT插件。 这在使用Kotlin注释处理工具中有记录 ,它说:

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

<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>

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>

更多推荐

本文发布于:2023-04-28 03:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329738.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:kapt   supported   maven

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!