-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure KAPT gradle plugin when an annotation processor is selected #438
Comments
@leonard84 start.spring.io doesn't know that entry is an annotation processor and I am not keen to bring that complexity at this point. I'd like to find another way to make it interoperable. Perhaps @sdeleuze knows? |
@snicoll I just tested it, you actually don't need to define the I haven't found a simple way for gradle to omit the |
I don't think that's the question. Annotation processors are automatically invoked with Java (it's part of the spec) so I'd rather have that with Koltin if we can. Implementing what you're asking means that initializr has to be aware that the dependency is in fact an annotation processor and I am not sure I like that idea. |
@snicoll if you want it to behave similar to Java then you just need to declare the You already put annotation processors into a special scope |
I disagree that |
Kotlin requires an explicit plugin declaration for annotation processors support and it is unlikely to change, so I don't see a better solution than adding an optional |
@sdeleuze you are describing the current situation and I think it can be improved (especially when one claims 100% interoperability with Java). I've created https://youtrack.jetbrains.com/issue/KT-18289 |
My request has been declined so we'll need to make this work here. |
Was anyone able to successfully use |
I have commented on KT-18022 to ask it to be reopened. |
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:
|
Any update regarding this? In addition to my lack of knowledge about the internal of this project, the discussion is also old, so not sure what comment is still relevant. But I'm a bit confused as to why this is proper to do here. There's already some logic to customize the build file if any annotation processor exists (e.g. |
Well, now, Kotlin says:
So, what is the right approach for spring configuration processor now? :-) |
OK, found spring-projects/spring-boot#28046 |
We've decided to restrict this fix to Gradle only. Unfortunately, supporting Maven is too challenging at this time as it requires us to hardcode the version of the annotation processor in one way or another and we're not keen to do that. I've created https://youtrack.jetbrains.com/issue/KT-59521/ to ask the Kotlin team to provide a feature of the plugin where it'd resolve the annotation processor version. |
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-18022The text was updated successfully, but these errors were encountered: