Debugging JetBrains/kotlin in IntelliJ

Hi all

I am currently investigating a bug in the kotlin-android-extensions plugin. To do this I need to debug the current unit tests in https://github.com/JetBrains/kotlin/tree/master/plugins/android-extensions/android-extensions-compiler from within IntelliJ. I have not yet made any changes from master.

Unfortunately, while the ReadMe for the Kotlin project suggests “there are Run/Debug Configurations for running IDEA or the Compiler Tests”, the only relevant run configuration is “Generate Compiler Tests”. As the name suggests this only generates the tests without running them and so is not sufficient.

In the Project tool window attempting to right click on plugins/android-extensions/android-extensions-compiler/test and choosing Debug, as you would for normal JUnit tests, results in the majority of tests failing as they are unable to resolve com.intellij.psi.PsiClassOwner or com.intellij.lang.java.JavaLanguage.

This can be resolved by replacing the gradle dependency line:

testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }

with:

testCompile(intellijCoreDep()) { includeJars("intellij-core") }

but the tests still fail unable to resolve com.intellij.serviceContainer.PlatformComponentManagerImpl or anthing in the android package.

This seems like quite the rabbit-hole. What is the correct approach to debug these tests within an IDE? I am hoping to make some progress this weekend if possible and would greatly appreciate your assistance.

Best regards