Skip to content

[major] [bug] Gradle projects add test compile path in the launcher configuration #507

Description

Run the attached project, and when checking the arg file, we can see that the bin/test is added into class path which cause issues when there are different resource files for testing purpose in applications.

micrometer-demo.zip

-cp "/Users/home/micrometer-demo/bin/main:/Users/home/micrometer-demo/bin/test:...

Activity

  1. gayanper commented on Aug 28, 2023

    @gayanper
    ContributorAuthor

    Related bug originally reported in eclipse-jdtls/eclipse.jdt.ls#2819

  2. gayanper commented on Aug 29, 2023

    @gayanper
    ContributorAuthor

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

  3. jdneo commented on Aug 31, 2023

    @jdneo
    Member

    Hey Gayan Perera (@gayanper)

    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
      Picture1
    • (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
      image
      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
      image
      in those two output channel if the new importer is working.
  4. gayanper commented on Sep 3, 2023

    @gayanper
    ContributorAuthor

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

  5. jdneo commented on Sep 4, 2023

    @jdneo
    Member

    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.

  6. hasanlovef commented on Apr 27, 2025

    @hasanlovef

    ...

  7. github-actions commented on Nov 17, 2025

    @github-actions

    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/test folder. 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" scope

    The 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions