I want to add annotations on my package. I can do ...
# spring
I want to add annotations on my package. I can do so with adding
file near my Kotlin code. It works while I run my app from IDE, but if I package app as a fat jar (
gradle bootJar
), it stops working. The only fix I came across is to place the package-info in
instead of
. Is there a way to instruct gradle to include package-info.java to resulting spring boot jar?
I don't think Kotlin knows about the package-info.java concept, so the compiler won't produce anything. I think your solution of putting it into the 'java' directory is the best one. Not sure why the IDE worked for you. I assume IDEA, so are you delegating builds to Gradle rather than IDEA?
Thanks for answering. Yes, I'm using IDEA. I think I don't delegate to gradle. At least my run configuration doesn't use gradle. Is there another way to mark packages besides annotation? What I'm trying to achieve is having my spring mvc requests logged in particular packages. Currently I'm using annotations on packages to "mark" them.
Sorry, I'm not understanding what you're trying to accomplish when you say 'mark packages'. Have you tried
https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets Or does the annotation need to be in a different place?
I'm injecting all spring-mvc handlers and I want to check whether I should register them to a particular place (so all requests/responses are being logged by my custom LoggingFilter). Instead of annotating each spring-mvc method or each class, I can annotate whole package so I can
Copy code
AnnotatedElementUtils.findMergedAnnotation(method.declaringClass.`package`, MyAnnotation::class.java)
I guess I'll resort to having package-info.java in