-
Notifications
You must be signed in to change notification settings - Fork 45
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
If both ksp and kapt plugins are available, both also create bean definitions #801
Comments
We don't support both KAPT and KSP at the same time. |
why do you want to use KAPT and KSP simultaneously? |
Some other annotation processor does not support ksp and probably never will and therefore i need to apply also the kapt plugin to use these. |
If KSP is present then the |
check needs to be added here micronaut-gradle-plugin/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautKotlinSupport.java Line 110 in 33d6859
|
The issue is that we cannot know when the kapt or ksp plugins are applied. So even if we add a check, it can fail. There's more going on than just the annotation processor being added too. |
But correct me if i am wrong: To apply the dependencies for kapt or ksp scope, it must know, that kapt or ksp are added, right? An alternative could be to disable kapt in the micronaut plugin via a config. |
Yes, we can do something when the KSP plugin is applied, or when the kapt plugin is applied. That's what we do. The thing is that we do it "twice" when both are applied. Disabling via configuration could be used too, but it's not that easy either because the flag could be set after the configuration was applied... |
Using
Interestingly, even if I run the Does Micronaut truly not support using both Even if that is the case, I feel like the behavior I'm seeing is especially cryptic and was extremely hard to troubleshoot. I have not found any other documentation anywhere that suggests that Micronaut does not support kapt and ksp simultaneously. If this is indeed the official policy, I would be happy to contribute docs updates. |
it is not supported to use both at the same time no, feel free to contribute docs to clarify this |
Expected Behavior
If both ksp and kapt plugins are available, only one should be used.
Actual Behaviour
If both ksp and kapt plugins are available, both also create bean definitions, which is inefficient. It also leads to and exception when building the jar:
However this can be resolved by specifying a duplicate strategy, but it is still inefficient. Sometimes kapt is also needed for other annotation processors.
Steps To Reproduce
mn create-app --build=gradle_kotlin --jdk=17 --lang=kotlin --test=junit com.example.demo
Environment Information
Example Application
https://github.com/braeluca/micronaut-kapt-ksp-demo
Version
4.0.3
The text was updated successfully, but these errors were encountered: