Hey guys, Mixing java + kotlin in a spring boot 2 ...
# spring
s
Hey guys, Mixing java + kotlin in a spring boot 2 app along with maven configuration is there any example available? The same app with gradle works fine but not with maven. Any ideas or hints about pom.xml configuration ?
a
l
shouldn’t it work to use start.spring.io and select Maven, Kotlin and 2.0.0 ? 🙂
👍 2
s
I am trying to mix java and kotlin, while the examples are purely for Kotlin.
The main problem comes when you put your java in src/main/java and kotlin to src/main/kotlin and java files cannot find the kotlin classes’ import
l
Ah alright. Gotcha. (I use gradle, so I don’t have that problem ;-))
s
exactly the same code runs in gradle with no issues
😞
c
You should put both kotlin and java in the same source directory. That will help you in the long run, both with configuration and with navigating your codebase, split packages are a huge headache when project grows.
initially my team also tried putting java and kotlin in
src/java
and
src/kotlin
respectively, we moved all kotlin code to
src/java
after a couple of weeks and never looked back
1
l
we actually did that, too (but G )
s
@Czar well yeah, that was our initial setup. But the generator that we are writing will be used by a lot of people (I guess so) so just to make sure that the setup is done perfectly. while I perfectly agree to have it both in the same folder.
But I think it is better to align with the standards here.
But this experiment is costing a lot of time 😞
c
I do not think there is such a standard
👍 1
s
Okayes then
c
To summarize I suggest not to, but if you really really want to do this, Kotlin official documentation does show how: https://kotlinlang.org/docs/reference/using-maven.html#compiling-kotlin-and-java-sources
👍 1
s
Yeah was experimenting with that and it is such a pain. I would rather not have it.
But if you can have a look at this repo https://github.com/jhipster/jhipster-kotlin the maven build is quite flaky( even after moving away from separate folders)
c
honestly I'm not a fan of jhipster, I don't know how it works internally, can you link the file you want me to look at?
s
just curious (not being fan of JHipster) why so? P.S. I am not gonna convince you, but seriously if we can address something then we are all ears 🙂
c
Well, last time I tried it was couple of years ago, the problem was it did too much and I had to redo too much, it was just easier to configure everything I needed how I needed myself from scratch.
👍 1
As I see, it is still the same, a lot of stuff I don't need in that huge 1000 LOC pom.xml 🙂
Sorry, it's too much, I won't be able to analyze what's going on properly to help you identify improvement points.
s
oops valid point… sorry
Interestingly I was able to compile the same with 1.2.20 (kotlin version) except that it complained that the classes are not open. (even after adding all-open related plugins) but in 1.2.21 I could not compile. Is there any known issue ?