javagradledependency-managementjdb

Gradle: How to debug a source code of a dependency


I'm using jdb debugger and I'd like to step into the dependency code. I'm using gradle as well. Here is my build.gradle

plugins {
    id 'java'
    id "io.spring.dependency-management" version "1.1.0"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
}

task runApp(type: JavaExec) {
    main = 'App'
    classpath = sourceSets.main.runtimeClasspath
}

I'm using a plugin, that should automatically download and manage the source code for my dependencies (io.spring.dependency-management). I'm not sure, if this is the right plugin.

But when I run

$ gradle clean
$ gradle build

and then I run jdb I can view my source code file but I can't view (list) the source code of a dependency.

What I'd like to achieve?

  1. step into the code of a dependency
  2. list the source code with the list command

How can I do it?


Solution

  • See this answer to download the sources of your dependencies : How can I use Gradle to download dependencies and their source files and place them all in one directory?

    Then, use the sourcepath jdb option to let him know where the sources are: jdb -sourcepath ".:/path/to/download".