feat: add Gradle build tool support for Java optimization#1774
feat: add Gradle build tool support for Java optimization#1774HeshamHM28 wants to merge 47 commits intomainfrom
Conversation
|
Claude finished @HeshamHM28's task in 6m 41s —— View job PR Review Summary
|
| File | Statements | Miss | Coverage |
|---|---|---|---|
gradle_strategy.py |
444 | 335 | 25% |
maven_strategy.py |
493 | 279 | 43% |
build_tool_strategy.py |
66 | 13 | 80% |
test_runner.py |
736 | 309 | 58% |
function_optimizer.py |
228 | 153 | 33% |
gradle_strategy.py at 25% is expected for a new file that requires a real Gradle project to exercise the I/O paths. The GradleStrategy methods that need coverage: ensure_runtime, install_multi_module_deps, get_classpath, run_tests_via_build_tool, run_benchmarking_via_build_tool, setup_coverage. These are all integration-level paths that are hard to unit test without mocking subprocess, but unit tests for the pure-logic helpers (_parse_classpath_output, get_reports_dir, get_build_output_dir) and the tree-sitter dependency injection (_find_top_level_dependencies_block, add_codeflash_dependency) would be straightforward to add.
Overall: The refactor to a strategy pattern is clean and the Gradle support looks solid. The two medium bugs (brace counting in setup_coverage and unqualified jacocoTestReport in multi-module builds) should be fixed before merging, as the E2E validation on Netflix Eureka/Zuul has already confirmed both are triggered in real projects.
⚡️ Codeflash found optimizations for this PR📄 73% (0.73x) speedup for
|
⚡️ Codeflash found optimizations for this PR📄 112% (1.12x) speedup for
|
⚡️ Codeflash found optimizations for this PR📄 84% (0.84x) speedup for
|
…2026-03-07T00.07.24 ⚡️ Speed up function `get_gradle_test_reports_dir` by 112% in PR #1774 (`feat/gradle-executor-from-java`)
|
This PR is now faster! 🚀 @claude[bot] accepted my optimizations from: |
⚡️ Codeflash found optimizations for this PR📄 413% (4.13x) speedup for
|
⚡️ Codeflash found optimizations for this PR📄 28% (0.28x) speedup for
|
- Updated tests in `test_java_multimodule_deps_install.py` to utilize `MavenStrategy` for installing multi-module dependencies. - Changed function calls from `ensure_multi_module_deps_installed` to `MavenStrategy.install_multi_module_deps`. - Added a fixture for `MavenStrategy` to streamline test setup. - Modified assertions and mock setups to align with the new strategy implementation. - Refactored tests in `test_java_test_filter_validation.py` to replace `_run_maven_tests` with `MavenStrategy.run_tests_via_build_tool`. - Adjusted test cases to ensure proper handling of empty and valid test filters. - Updated mock setups for Maven executable and command execution to reflect changes in the strategy.
41a4e02 to
f4a4ac6
Compare
Replacing the chained `/` operator (`build_root / test_module / "target"`) with `build_root.joinpath(test_module, _TARGET)` eliminates the intermediate Path object created after `build_root / test_module`, cutting per-call overhead from ~15.9 µs to ~10.4 µs in the hot path (3323 hits). The profiler shows the hot line dropped from 97.3% to 96.3% of runtime, and hoisting `"target"` into a module constant `_TARGET` avoids repeated string allocations. Runtime improved 51% (9.70 ms → 6.40 ms) with no functional regressions across all test cases.
⚡️ Codeflash found optimizations for this PR📄 52% (0.52x) speedup for
|
…2026-03-09T22.13.14 ⚡️ Speed up method `MavenStrategy.get_build_output_dir` by 52% in PR #1774 (`feat/gradle-executor-from-java`)
|
This PR is now faster! 🚀 @HeshamHM28 accepted my optimizations from: |
The optimized code eliminates two allocation-heavy steps in `_validate_test_filter`: building an intermediate list via `[p.strip() for p in test_filter.split(",")]` and unconditionally calling `pattern.replace("*", "A")` even when no wildcard exists. By iterating directly over `split(",")` and guarding `replace` with an `if "*" in pattern` check, the hot loop avoids ~2.5 ms of string allocations per 1000-pattern call (profiler shows the list comprehension took 11.6% of original time). Additionally, replacing `bool(_VALID_JAVA_CLASS_NAME.match(...))` with `... is not None` in both functions removes unnecessary type conversions, though the filter loop accounts for the bulk of the 26% runtime improvement across Maven test-execution paths that validate comma-separated test filters.
⚡️ Codeflash found optimizations for this PR📄 27% (0.27x) speedup for
|
⚡️ Codeflash found optimizations for this PR📄 13% (0.13x) speedup for
|
…2026-03-09T22.52.33 ⚡️ Speed up function `_validate_test_filter` by 27% in PR #1774 (`feat/gradle-executor-from-java`)
|
This PR is now faster! 🚀 @claude[bot] accepted my optimizations from: |
Matches Maven's -Dmaven.test.failure.ignore=true and -DfailIfNoTests=false so coverage runs complete jacocoTestReport and multi-module --tests filters don't abort on modules with no matching tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace fragile brace-counting string manipulation with tree-sitter Groovy/Kotlin parsers to find the top-level dependencies block. This correctly ignores nested blocks inside buildscript, subprojects, etc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-x taskName fails if the task doesn't exist, breaking projects without those plugins. Init script safely disables tasks only if present, matching Maven's -Dcheckstyle.skip=true behavior which is silently ignored. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Blocker: Error Prone
|
- Remove duplicate setup_test_config method in JavaSupport - Fix import sort order in support.py - Fix superfluous-else-return in test_runner.py - Add missing newline at end of build_tools.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
⚡️ Codeflash found optimizations for this PR📄 21% (0.21x) speedup for
|
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
⚡️ Codeflash found optimizations for this PR📄 22% (0.22x) speedup for
|

Summary
--init-scriptrun_behavioral_tests,run_benchmarking_tests,run_line_profile_tests) based ondetect_build_tool()_run_tests_direct) for the fast compile-once-run-many patternFiles changed
build_tools.pytest_runner.pyconfig.pyTest plan
ruff checkandruff formatpasscodeflash optimizetest blocked by SSL certificate issue in environment (API unreachable)🤖 Generated with Claude Code