fix: Maven find_executable() walks up from build_root instead of checking CWD#1945
fix: Maven find_executable() walks up from build_root instead of checking CWD#1945mashraf-222 wants to merge 1 commit intomainfrom
Conversation
…king CWD
The CWD-based `Path("mvnw").exists()` fallback returned a relative
"./mvnw" that failed with FileNotFoundError when subprocess ran with
cwd=<submodule>. Now walks up parent directories from build_root,
matching the pattern already used by GradleStrategy.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @mashraf-222's task in 2m 32s —— View job PR Review Summary
Prek ChecksAll clean — prek passes with no issues on changed files. Code ReviewThe fix is correct and well-implemented.
One minor observation: the old code had a fast-path check for Tests —
The No issues found. Duplicate DetectionThe new Optimization PRPR #1943 ( |
Problem
MavenStrategy.find_executable()had a fallback that checkedPath("mvnw").exists()against Python's current working directory instead of thebuild_rootparameter. This returned a relative"./mvnw"path that causedFileNotFoundErrorwhen the subprocess ran withcwd=<submodule>where nomvnwexists.Impact: 100% of test executions failed in multi-module Maven projects (Hazelcast, Spring Framework, etc.). In a Hazelcast sweep, 282 functions all crashed at test execution — 4.5 hours wasted.
Root Cause
maven_strategy.py:656-659— CWD-based check returns a path relative to the wrong directory:When subprocess later runs with
cwd=build_root(the submodule dir),./mvnwdoesn't exist there.Fix
Replaced the CWD-based fallback with parent-directory traversal — the same pattern
GradleStrategy.find_executable()already uses correctly. Walks up frombuild_rootto findmvnwin any ancestor directory, always returning an absolute path.Validation
Bug replicated before fix:
Fix confirmed after change:
E2E validation: Fibonacci optimization on java-test-project completed without FileNotFoundError (single-module regression check passed). Hazelcast multi-module scenarios verified via targeted Python tests (3/3 pass).
Test Coverage
test_find_wrapper_in_parent_directory— mvnw at repo root, build_root is submoduletest_find_wrapper_in_grandparent_directory— mvnw two levels up from build_roottest_no_wrapper_returns_system_mvn_or_none— no wrapper anywhere, falls back to system mvntest_cwd_does_not_affect_result— CWD has mvnw but build_root doesn't — no contaminationCloses CF-1079