What are the possible consequences if I ignore ‘Pa...
# announcements
m
What are the possible consequences if I ignore ‘Package directive doesn’t match file location’ issue?
r
Outside an IDE it may confuse people… at usage site people wanting to navigate to the declaration may expect to find it at the directory implied by the package.
There are (in my view) valid use cases though: https://youtrack.jetbrains.com/issue/KT-40623
IntelliJ has he concept of a “packagePrefix” so you can omit the directories that are common to all packages in a module; e.g. if you had a module
foo
where all packages are subpackages of
com.mycompany.myapp.foo
you can set the package prefix to that and then
com.mycompany.myapp.foo.Foo
can be in
src/main/kotlin/Foo.kt
rather than
src/main/kotlin/com/mycompany/myapp/foo/Foo.kt
. You can set it in gradle as so https://youtrack.jetbrains.com/issue/IDEA-240235
m
Thanks, I’ll dig into that.