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

When debugging in VSCode, maven dependencies with "test-scope" are not available

Open Frickeldave opened this issue 4 years ago • 2 comments

Describe the bug When i debug a maven based java application in VSCode the dependencies which are defined in the "test-scope" are not loaded and therefore it is not possible to debug an application when a component is needed which is marked for the test-scope. A workaround is to remove the test-scope, but then it is also part of my productive deployment which is not my goal. Another workaround is probably using maven profiles. But this increased the complexity.

To Reproduce Steps to reproduce the behavior:

  1. Create a maven based project
  2. Create the H2 dependeny with scope test e.g. <groupId>com.h2database</groupId> <artifactId>h2</artifactId> 1.4.200 test
  3. Create an application (e.g. spring boot) which use H2 (example is here)
  4. Run debug
  5. Application will fail when connecting

Expected behavior A switch/option/setting to define the maven scope when debugging an application.

Environments (please complete the following information as much as possible):

  • OS: Windows 10
  • VS Code version: 1.48.2
  • Extension version Java extension pack 0.10.0

Frickeldave avatar Oct 08 '20 09:10 Frickeldave

When i debug a maven based java application in VSCode the dependencies which are defined in the "test-scope" are not loaded and therefore it is not possible to debug an application when a component is needed which is marked for the test-scope.

It's more related to Java debugger, you'd better open the issue there to get more help.

/cc @testforstephen

Eskibear avatar Oct 13 '20 00:10 Eskibear

When running a normal application, the debugger won't include the dependencies marked as test scope. This is by design.

If you reference the doc at https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope, test scope should only be for test purpose.

  • test This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.

testforstephen avatar Oct 13 '20 02:10 testforstephen