fix: Test Explorer discovery and debug classpath resolution for Bazel Java targets#27
Merged
monkey666-cr merged 4 commits intoMay 26, 2026
Conversation
Fix VS Code Test Explorer not discovering @Test-annotated tests by: 1. Propagate isTest flag from Rust TargetKind::JavaTest through JNI to source entries, marking test folders with IClasspathAttribute.TEST. This unblocks vscode-java-test's isTestFile check. 2. Resolve fallback JARs from Bazel's external cache when build artifacts don't exist. JUnit and other test JARs cached at <output_base>/external/ are now found even before first build, enabling JDT SearchEngine to resolve @test annotation class. 3. Add BazelExternalRepoResolver utility for output_base discovery and external repo JAR lookup, with fallback to both classic and bzlmod repository layouts. All classpath entries now correctly decorated with test=true attribute, test sources are marked at project level, and missing JARs gracefully resolve from cache or skip with warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t JARs The Java Test Runner pre-resolves classPaths before our debug config provider runs. When a Bazel target hasn't been built yet, output JARs don't exist on disk and are skipped by fileExists() during resolution. Our buildTarget creates those JARs, but config.classPaths is already frozen — causing ClassNotFoundException on first Run/Debug. After buildTarget, re-resolve the classpath via vscode.java.resolveClasspath and merge any new entries into the existing classPaths. We merge rather than replace to preserve test-runner infrastructure JARs (RemoteTestRunner). Also reorders handleBuildTarget post-build steps: resetWarnings → setMergedClasspathContainer(force=true) → clearCacheForProject. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BazelProjectCreator uses Platform.getLog() which requires OSGi runtime, causing ExceptionInInitializerError in CI where no OSGi container runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isTestflag from Rust through JNI, resolve fallback JARs from Bazel external cache, and addBazelExternalRepoResolverfor classic/bzlmod layouts.buildTargetcompletes, re-resolve classpath viavscode.java.resolveClasspathand merge new entries to fixClassNotFoundExceptionon first Run/Debug.Test plan
@Testannotated tests in Bazel Java projectsClassNotFoundExceptionisTest=true) for test sources<output_base>/external/before first buildcargo test --workspace— all Rust tests passmvn test— all Java tests pass (including new tests forBazelExternalRepoResolver,BazelClasspathContainer,BazelProjectCreator)🤖 Generated with Claude Code