Repository navigation
fix(workspace): honor project(":name").projectDir relocation in settings.gradle - #327
Merged
Merged
Conversation
…ngs.gradle
Module directory discovery derived every subproject's path purely from
its include(":name") string, ignoring a subsequent
project(":name").projectDir = file("...") relocation. A project that
groups its modules under a parent directory (include(":kmp-module-one")
building from modules/kmp-module-one/, not ./kmp-module-one/) had that
module's source roots silently lost — detect_build_layout_source_paths
probed a directory that doesn't exist, read_dir failed, and the module's
src/*/kotlin dirs never became source roots. Highlighting still worked
(per-file, source-root-independent); navigation and find-references,
which depend on correct source-root scoping, mostly didn't.
Fixes #326.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7ZonwYUh94VsuQphiHykF
Review found two gaps: no test covered a project(...) line that starts
correctly but configures something other than projectDir (only the
!starts_with("project(") disjunct was exercised); the non-relocated-module
test only checked isolated parse_project_dir_overrides output rather than
settings_subprojects' real unwrap_or(dir) fallback path end-to-end.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7ZonwYUh94VsuQphiHykF
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
Fixes #326. A project that groups its modules under a parent directory in
settings.gradle.ktsviaproject(":name").projectDir = file("modules/name")had that module's source roots silently lost:settings_subprojectsderived every module's directory purely from theinclude(...)string, never reading aprojectDirrelocation.detect_build_layout_source_pathsthen probed a directory that doesn't exist,read_dirfailed, and the module'ssrc/*/kotlinroots never got discovered — explaining the reporter's exact symptom (highlighting fine, navigation/find-references mostly broken, since highlighting is per-file and source-root-independent while cross-file resolution depends on correct source-root scoping).parse_project_dir_overridesparsesproject(":name").projectDir = ...lines (Kotlin DSLfile(...), Groovynew File(...), or a bare string — all just one quoted name + one quoted path per line), robust to same-line comments/interpolation (degrades to a harmless no-crash mismap, never a panic).settings_subprojectsnow maps each include-derived directory through the override when one exists; both existing callers (detect_build_layout_source_paths,detect_android_r_class_jars) get the fix for free, untouched.projectDiroverrides (confirmed: empty override map →unwrap_or(dir)is a no-op for every entry).Test plan
settings_gradle_relocated_module_dir_is_discovered— end-to-end, reproduces the reporter's exactsettings.gradle.ktsshape; confirmed genuinely RED without the fix (temporarily reverted, reran, real panic; restored)parse_project_dir_overrides: Kotlin DSL, Groovynew File(...), bare string, two negative/decoy cases (aproject(...)reference with no.projectDirat all; aproject(...).projectDir-shaped line that configures something else)settings_subprojects_passes_through_a_non_relocated_module_unchanged— mixed relocated + non-relocated project, exercises the realunwrap_or(dir)fallback end-to-endcargo test(2020 passed),cargo clippy --all-targets -- -D warnings(clean),cargo fmt(clean)parse_include_callsfor nested modules, confirmed cross-platform path-join correctness for the Windows separator case) — two test-coverage gaps found and fixed before this push🤖 Generated with Claude Code
https://claude.ai/code/session_01L7ZonwYUh94VsuQphiHykF