Description
Expected Behavior
Java and Kotlin code should work in harmony, where only one bean (and one path mapping) per Java class gets generated. This bug happened when adding Kotlin code to an existing Micronaut Java app containing Java Micronaut Controllers.
keepJavacAnnotationProcessors
in kapt is enabled so Lombok in Java still compiles.
If keepJavacAnnotationProcessors = true
is emitted from build.gradle
then everything works as expected.
Actual Behaviour
Duplicate beans and endpoints get instantiated so endpoint returns Bad Request as Micronaut doesn't know which endpoint to choose. Internally in Micronaut the classloader returns resources both from build/classes/java
and build/tmp/kapt3/classes
, which Micronaut creates beans from and therefore duplicate controllers.
Steps To Reproduce
- Clone https://github.com/korri123/MicronautErrorTest
- Run the test file named
src/test/kotlin/com/example/DemoTest.kt
which should succeed as it asserts the error message happens.
Environment Information
- Ubuntu 20.4
- JDK 17
Example Application
https://github.com/korri123/MicronautErrorTest
Version
3.4.2