Repository navigation
[major] [bug] Gradle projects add test compile path in the launcher configuration #507
Description
Activity
gayanper commented
on Aug 28, 2023 ContributorAuthorMore actionsRelated bug originally reported in eclipse-jdtls/eclipse.jdt.ls#2819
gayanper commented
on Aug 29, 2023 ContributorAuthorMore actionsI have checked how the Eclipse UI generate the run command. It seems when Exclude test code is used, it uses the output path, bin/default and when Exclude test code is not used, both bin/main and bin/test are added.
And in the extension scenario we end using all 3 paths always. When debugging it was found that bin/test comes as part of bin/test/generated-sources/annotations 's output location.
Either we can report this to buildship to add support in this scenario to provide correct paths as in Eclise or we can filter the output paths looking and the project raw classpath's output locations.
We recently just released a new tool to support Gradle project - Build Server for Gradle, maybe that can help solve your problem.
If you are interested, please follow the steps below:
- install the latest pre-release of Gradle for Java extension

- (Optional) If you are using VS Code stable, set the setting
"java.gradle.buildServer.enabled"to"on". Skip this if you are using Insiders - Run
Java: Clean Java Language Server Workspace>Reload and Delete - After reload, if you still see

in the Java Projects explorer, it indicates that the project is still imported by Buildship, you need to clean and reload again. (This is caused by some issues that the bundle is not registered for the first time in a new workspace) - You should see logs

in those two output channel if the new importer is working.
- install the latest pre-release of Gradle for Java extension
gayanper commented
on Sep 3, 2023 ContributorAuthorMore actionsYes that seems to fix this issue, So I think we can close this if this build-server is the future for gradle projects, But if we are keeping the possibility to use buildship I think we might need to find away to resolve this.
The long-term plan is to leverage bs approach to support the Gradle project. But since currently we are still in the exploring phase for the bs approach, maybe keep this issue open until we make the decision to use BS to replace Buildship in VS Code.
...
Hi Gayan Perera (@gayanper), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Potential workaround
• Explicitly override the generated launch configuration to omit the
bin/testfolder. For example, in .vscode/launch.json:{ "configurations": [ { "type": "java", "name": "Launch MicrometerDemo", "request": "launch", "mainClass": "com.example.Main", "classPaths": [ "${workspaceFolder}/bin/main" ] } ] }This forces only the main output on the classpath.
Related issues
• Duplicate of the same report in the Eclipse JDT LS repo:
– #2819 – Gradle projects add test compile path in the launcher configuration• A similar problem in the VS Code Java Debug extension, no workaround yet:
– vscode-java-debug#1008 – Test dependencies and output are placed to "Runtime" scopeThe team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
Run the attached project, and when checking the arg file, we can see that the
bin/testis added into class path which cause issues when there are different resource files for testing purpose in applications.micrometer-demo.zip