Hello, World! I've created a class in the `kotlin...
# intellij
b
Hello, World! I've created a class in the
kotlin
root folder, and added a
package
declaration. I'm used to see a warning for this case, saying that the package doesn't match the directory structure (with an intention to move it). But it doesn't currently do it (no warning) - I'm on a Multiplatorm project, not sure if that's a factor. Ideas?
w
Iirc classes in root folder don’t have package warnings even for non-multiplatform projects
b
weird 🙂
r
Official Kotlin codestyle proposes not to create directories for common components of package, e.g. for class
org.example.mylib.listeners.MyListener
in module
mylib
you'll have the following file:
mylib/src/main/kotlin/listeners/MyListener.kt
. This doesn't work properly for projects with mixed Kotlin and Java (or Android, IIRC), and also of course there are heuristics which detect mismatches in packages seeing old style of package<>directory mapping. So it's quite a possibility you've seen this for the first time, and this is as intended :) If you don't want to follow this route, creating first Kotlin class with a full path should reenable the warning for next ones.
b
Thanks a lot! Indeed I wasn't aware of this at all 🙂 (and yes I do mostly Android dev). 👍