question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure KAPT plugin when an annotation processor is selected

See original GitHub issue

The initializr should generate the appropriate entries for KAPT if the language is Kotlin and the ConfigurationProcessor is selected as dependency.

In gradle you just need to add the processor as an dependency to the kapt configuration: dependencies { kapt "org.springframework.boot:spring-boot-configuration-processor" } https://stackoverflow.com/questions/37858833/spring-configuration-metadata-json-file-is-not-generated-in-intellij-idea-for-ko

Maven is a bit more verbose https://kotlinlang.org/docs/reference/kapt.html and requires declaration of the kapt goal. However, there is an open issue that prevents kapt from working if a compiler plugin (e.g. kotlin-maven-allopen) is added as dependency https://youtrack.jetbrains.com/issue/KT-18022

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
dima767commented, Jan 15, 2018

Was anyone able to successfully use kapt to generate spring boot configuration metadata? I’ve created the simplest possible project with Gradle, but when I run build nothing happens. https://github.com/dima767/bootiful-kt-with-config-metadata-processing If someone could point me to a right direction that would be appreciated!

3reactions
aleskiewiczcommented, Apr 21, 2021

I am not sure if the issue in kotlin is still present… I was able to make it working using following configuration:

            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                    </compilerPlugins>
                </configuration>
                <executions>
                    <execution>
                        <id>kapt</id>
                        <goals>
                            <goal>kapt</goal>
                        </goals>
                        <configuration>
                            <annotationProcessorPaths>
                                <annotationProcessorPath>
                                    <groupId>org.springframework.boot</groupId>
                                    <artifactId>spring-boot-configuration-processor</artifactId>
                                    <version>${spring-boot.version}</version>
                                </annotationProcessorPath>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

Perhaps this info from kapt docs is also relevant:

Please note that kapt is still not supported for IntelliJ IDEA’s own build system. Launch the build from the “Maven Projects” toolbar whenever you want to re-run the annotation processing. https://kotlinlang.org/docs/kapt.html#using-in-maven

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using kapt | Kotlin
By default, kapt runs all annotation processors and disables annotation processing by javac. However, you may need some of javac's annotation ...
Read more >
Configure annotation processors | IntelliJ IDEA Documentation
Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Compiler | Annotation Processors.
Read more >
Android project with Java and Kotlin files, kapt or ...
First of all, the Kotlin Annotation processing tool (kapt) uses the Java compiler to run annotation processors. If your project contains any ...
Read more >
Android/Kotlin Series: [#03] Kotlin plugin should be enabled ...
Kotlin plugin doesn't pick up annotationProcessor dependencies, So we have to use kapt dependencies with kotlin-kapt . Use the latest version of Kotlin ......
Read more >
The Guide To Your First Annotation Processor with KSP (And ...
In this article, we are going to create ListGen, a KSP-based library that creates a list out of all the functions that have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found