redhat-developer / redhat-developer/vscode-java

vscode generates compile errors for valid test-jar dependencies

Open
#4,146 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

I have a non shipping "utility" maven module. It has a dependency on classes from a test-jar produced by another module. If both the utility maven module and the test-jar producing module are loaded in the workspace, vscode generates compile errors for all imported test-jar classes. See the first screenshot below. Note that the compile errors in vscode are incorrect and should not exist. In contrast, running "mvn clean install" results in a successful build and IntelliJ handles this situation fine (there are no compile errors).

If however the module that produces the test jar is not loaded in the workspace, there are no compile errors for the imported test-jar classes in vscode. See the second screenshot below. In otherwords, the compile error only shows up when the test-jar producing module is in the workspace with the test-jar consuming module. Apparently vscode/eclipse jdt cannot resolve the test classes when they are from a local project and imported by another project's src/main classes.

I will attach 2 small maven projects to demonstrate the problem. You can load them into vscode to reproduce. You can also build them from the command line with mvn to confirm they are valid.

Compile error when both test-jar consuming and producing projects are in the workspace
Image

No compile error when the test-jar producing project is not in the workspace
Image

test-jar-issue-projects.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by opening test-jar-issue-projects.zip in VS Code with both Maven projects loaded, then compare the diagnostics with a workspace containing only the consuming project. Run mvn clean install to confirm the projects are valid; done means local test-jar imports no longer produce false compile errors when both projects are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.