vscode-kotlin
vscode-kotlin copied to clipboard
Unable to get debugger to work with gradle project
We are facing issues getting the debugger to work. We manage to point to the main class and get it to compile, unfortunately, since the project is run by Gradle, we cannot find a way to specify the necessary dependencies for the kotlin compiler.
The actual error we get is "Unresolved reference" which is understandable since the dependencies are not loaded.
Steps to reproduce:
- Create a sprint web project for Kotlin in here https://start.spring.io/
- Compile with Gradle
That sounds weird as I have debugged Spring Boot apps using Gradle many times. The dependencies should be fetched automatically from the build files. Make sure of some things:
- The main class name needs to be correct. Remember that Kotlin classes have Kt at the end of the name unless otherwise specified (with the
JvmName
annotation). If your file is DemoApplication, then the main class will be DemoApplicationKt. This is the issue I see most often, as people forget that the classes have the Kt at the end 🙂 - Everything is built in a normal way (i.e, no special trickery with where build classes etc. are put). You mention compiling, I guess that means building the entire project with gradle build?
There should also be a run/debug-panel next to your main class in the VSCode extension, especially in the newer versions. That should fix the main class for you.