Source Directory Structure: Hard to Debug in Spring


#1

Hi,
after spending hours debugging a bean resolution problem in Spring, ended up finding out that the problem was about a “feature” of Kotlin. If I am not mistaken, in contrast to Java, you can have package declarations that do not match the source code directory layout. Problem is that SpringBoot is based on bean resolution on packages. If you have a misspelled package name (or a wrong copy&paste), the build still proceed with no error. IntelliJ inspection marks it as a warning, but it is easy to miss it (especially the first time you encounter this “feature”). To avoid major frustrations when working with SpringBoot, it would be great if the Kotlin compiler would fail the build if such name mismatch happens (if not on by default, at least make it controllable from a configuration setting). Or is there already some existing solution for this problem? Sorry for the tone of this message, but it has been a very frustrating few hours… :frowning:

many thanks


#2

The only way I can see to do this right now is to use TeamCity for continuous integration. TC has an option where you can fail builds based on IntelliJ inspections.

Edit: and now I’m reminded that that isn’t really true. There are linters (like ktlint and Detekt) that you can integrate into your build process.


#3

ktlint and Detekt seem like they would do the job… thanks!!! :wink: