vscode-kotlin icon indicating copy to clipboard operation
vscode-kotlin copied to clipboard

Unable to get debugger to work with gradle project

Open jose-heatly opened this issue 2 years ago • 1 comments

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:

  1. Create a sprint web project for Kotlin in here https://start.spring.io/
  2. Compile with Gradle

jose-heatly avatar Nov 18 '22 09:11 jose-heatly

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:

  1. 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 🙂
  2. 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.

themkat avatar Nov 29 '22 17:11 themkat