Skip to content

feat: eager test discovery and JAR fallback resolution improvements#29

Merged
monkey666-cr merged 2 commits into
monkey666-cr:mainfrom
runchen0919:feat/eager-test-discovery
May 27, 2026
Merged

feat: eager test discovery and JAR fallback resolution improvements#29
monkey666-cr merged 2 commits into
monkey666-cr:mainfrom
runchen0919:feat/eager-test-discovery

Conversation

@runchen0919

@runchen0919 runchen0919 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Auto-refresh test discovery: Trigger testing.refreshTests via vscjava.vscode-java-test after initial JDT.LS import (serverReady()) and scope-change re-imports, so tests are discovered eagerly without manual intervention
  • JAR fallback resolution for 3rdparty wrapper targets: Resolve missing Bazel build-output JARs (e.g., bazel-out/.../bin/3rdparty/lib<name>.jar) to their actual JARs in the external repository cache, fixing classpath gaps for targets like //3rdparty:junit

Changes

Extension (TypeScript)

  • Auto-refresh test discovery after Bazel project import via serverReady() and scope-change re-imports

Java Bridge

  • Add resolveBuildOutputJar() to handle lib<name>.jar pattern matching and repo search
  • Add extractArtifactNameFromLibJar() to extract artifact name from filename
  • Add findCandidateRepoDir() to search external/ with priority: exact_double > exact_single > prefix > bzlmod
  • Update resolveFallbackJar() to call new build-output resolution when /external/ path resolution fails
  • Add clearActiveDebugProject command handler and onDidTerminateDebugSession handler
  • Add 15 new unit tests

Test plan

  • Open a Bazel Java project — tests should auto-appear in Test Explorer after import without manual refresh
  • Verify //3rdparty:junit and similar wrapper targets appear in test classpaths
  • Run existing test suite: mvn test -Djava.library.path=../target/release
  • Confirm debug sessions clear activeDebugProject on termination

🤖 Generated with Claude Code

runchen0919 and others added 2 commits May 26, 2026 18:50
Resolve missing Bazel build-output JARs (e.g., bazel-out/.../bin/3rdparty/lib<name>.jar)
to their actual JAR files in the external repository cache. This fixes the issue where
3rdparty java_library wrapper targets (like //3rdparty:junit) produce output JARs that
don't exist after aspect-only builds, causing them to be silently dropped from the classpath.

Changes:
- Add resolveBuildOutputJar() to handle lib<name>.jar pattern matching and repo search
- Add extractArtifactNameFromLibJar() to extract artifact name from filename
- Add findCandidateRepoDir() to search external/ with priority: exact_double > exact_single > prefix > bzlmod
- Update resolveFallbackJar() to call new build-output resolution when /external/ path resolution fails
- Add clearActiveDebugProject command handler to clear debug session gating
- Add onDidTerminateDebugSession handler to call clearActiveDebugProject on debug end
- Add comprehensive unit tests (15 new test cases)

This ensures that tests can find JUnit and other 3rdparty dependencies even when the aspect
build doesn't materialize the wrapper JAR on disk.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Trigger testing.refreshTests via vscjava.vscode-java-test after:
- Initial JDT.LS import (via serverReady())
- Scope-change re-imports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@monkey666-cr monkey666-cr merged commit 2eda4f7 into monkey666-cr:main May 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants