What is the proper way to debug multi-module maven project with VSCode?

Viewed 1003

Here's some background to my particular case. I was given a multi-module maven project and opened the entire project as one workspace in VSCode. The modules are deployed to a JBoss server as .war files. Each module has its own artifactId and can make calls to other modules (through HTTP or other protocols). I created a launch.json file in .vscode directory. This .vscode directory sits among other modules right under the project root. The launch.json file contains the following content:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "java",
      "name": "Debug (Attach) - Remote",
      "request": "attach",
      "hostName": "<ip_address>",
      "port": 8787
    }
  ]
}

This works if I don't need to evaluate statements in the debug console. I could also add "projectName": "<artifactId>" when I need to evaluate statements for a single module. However, I could not debug multiple modules at one time. What I'm currently doing is to 1) stop the debugger, 2) edit projectName to the next module's artifactId, 3) attach the debugger again (and fire a new request). This doesn't sound like the optimal way of debugging this type of projects in VSCode. Note that I also tried to put the parent POM artifactId or even the project root directory name as projectName, but they didn't work neither (in this case, it simply says "Cannot evaluate because of java.lang.IllegalStateException: Project <name> cannot be found").

0 Answers
Related