I forced java version into build.gradle.kts
like this
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
which fixed the problem. I could remove the snippet later and build would work without it. I guess idea or gradle cache everything forever.