Repository navigation
Conversation
Previously, _find searched reversed(range(len(segments))) for 'java' or 'javatests', causing any package folder named 'java' (e.g., src/test/java/com/acme/java/extensions) to be matched as the source root instead of the actual source root directory. Updates _get_java_segments to prioritize standard Maven/Gradle source roots (src/(main|test)/(java|javatests|kotlin)), test root directories (javatests), and earliest source root segments so package segments named 'java' are correctly preserved. Fixes google#290
Author
Implementation DetailsThe previous logic used _find(segments, root) with The updated _get_java_segments handles:
|
This branch has not been deployed
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.
Description
Fixes #290.
When running
j2cl_teston projects with classpaths that contain a package component namedjava(such assrc/test/java/com/acme/java/extensionsorsamples/helloworld/src/test/java/com/google/j2cl/samples/java), the package name extraction inj2cl_util.bzlbroke because_findsearched backwards from the rightmost segment. This caused the inner package folder namedjavato be treated as the root directory, stripping the prefix and breaking test suite generation.Solution
Updates
_get_java_segments(path)inbuild_defs/internal_do_not_use/j2cl_util.bzlto:src/(main|test)/(java|javatests|kotlin)).javatests) as used in Bazel/Google monorepos.javaorkotlin).This ensures package directory components named
javaare correctly preserved as part of the package name.