1

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?

Vampire
  • 35,631
  • 4
  • 76
  • 102
xralf
  • 3,312
  • 45
  • 129
  • 200
  • 3
    The Spring dependency management plugin has nothing to do with source code. It only allows to control dependency versions coming from BOMs. Actually, it is a relict from times when Gradle had no built-in BOM support. Even the maintainer of that plugin recommends to not use it anymore, but instead use the built-in BOM support. But anyway this has nothing to do with your actual question either way. – Vampire Jun 12 '23 at 22:12

1 Answers1

1

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".

Seb Perp
  • 276
  • 1
  • 9
  • 1
    Be very careful when doing this. Artifact resolution queries for example are not variant / attribute aware. There is unfortunately not yet a proper replacement that is which is the main reason it is still in there and not deprecated, but it should be used with caution. – Vampire Jun 15 '23 at 15:40