When using Kotlin <=15.10 everything works as expected. Then I switch to Kotlin 1.5.20. During reloading of gradle project following error occurs in the event log:
This is an unexpected error. Please file a bug containing the idea.log file.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Unable to load class ‘org.antlr.v4.runtime.Lexer’
This is an unexpected error. Please file a bug containing the idea.log file. (5 s 686 ms)
2021-07-19 22:19:13,432 [2633513] WARN - e.project.sync.GradleSyncState - Unable to load class ‘org.antlr.v4.runtime.Lexer’.
This is an unexpected error. Please file a bug containing the idea.log file.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Unable to load class ‘org.antlr.v4.runtime.Lexer’.
What could it be, that with change of the Kotlin version suddenly such a problem occurs?
It looks like you are hitting the same issue I had, try to fetch the kotlin plugin from mavenCentral() instead of maven("https://plugins.gradle.org/m2/"), it might help.
The POM coming from the gradle repo is wrong for some reason.
There is mentioned that there seem to be problems with generateExternals = true. And indeed, when I comment out the lines, where externals are generated and replace with a version without generating externals, then it works. Thus it seem to go in that direction. My dependencies block is now looking like that:
I don’t even find a place, where maven("https://plugins.gradle.org/m2/") is set. Do you mean the repositories block in the build.gradle.kts or do you mean any property digged in the settings. My repositories block looks like this
Plugins use the gradle repo by default and do not use the same repo as the regular dependencies
There is a documentation on how to customize plugin resolution, this is where you want to put mavenCentral() first and maven("https://plugins.gradle.org/m2/") second so maven central has priority.