This repo includes a demo application to reproduce the bug https://youtrack.jetbrains.com/issue/IDEA-341184#focus=Comments-27-8732842.0-0 where IntelliJ does not build changes automatically when the project is open under WSL2 (Windows).
A screencast of the issue can be seen here: https://drive.google.com/file/d/1XaHv_r5Eqh8ch26YrUsnpakkNhVYWgkY/view?usp=sharing
NOTE: IntelliJ under a Windows environment builds the project correctly, see another screenshot: https://drive.google.com/file/d/1POLvz2KgiXVROEsqRb83Fl8559Hhq66x/view?usp=sharing