Skip to content

feat(mvn): add Maven (Java) filter module — test, compile, checkstyle:check, dependency:tree - #1089

Closed
mariuszs wants to merge 33 commits into
rtk-ai:developfrom
mariuszs:feat/mvn-rust-module
Closed

mariuszs wants to merge 33 commits into
rtk-ai:developfrom
mariuszs:feat/mvn-rust-module

Conversation

@mariuszs

@mariuszs mariuszs commented Apr 8, 2026 •

Copy link
Copy Markdown

Summary

Maven/Java ecosystem support for RTK.

Subcommands

Command Savings
rtk mvn test 99%
rtk mvn verify 95%
rtk mvn compile 85%
rtk mvn checkstyle:check 90%
rtk mvn dependency:tree 70%
rtk mvn clean 95%

Plus rtk mvnd — same filters for Maven Daemon. Unrecognized goals pass through with metrics.

For test/verify, RTK reads target/surefire-reports/ and target/failsafe-reports/
XML to surface structured failure details (class, method, exception, message) with
compact stack traces — Caused-by chains preserved, framework frames
(org.junit.*, java.base/*, org.apache.maven.*) collapsed to keep app frames
visible. Auto-detects mvnw wrapper.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test --all passes
  • Snapshot tests (insta) for every filter
  • Token savings verified on real Maven fixtures
  • Manual test on real Maven project

@CLAassistant

CLAassistant commented Apr 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mariuszs
mariuszs changed the base branch from master to develop April 8, 2026 20:11
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch 9 times, most recently from 5d7c9a2 to 8baf6bd Compare April 14, 2026 12:46
@mariuszs mariuszs changed the title feat(mvn): add Maven filter module — test, build, dependency:tree feat(mvn): add Maven (Java) filter module — test, build, dependency:tree Apr 14, 2026
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from 6edc416 to b44c8f7 Compare April 14, 2026 13:10
@mariuszs
mariuszs marked this pull request as draft April 14, 2026 15:23
@mariuszs mariuszs changed the title feat(mvn): add Maven (Java) filter module — test, build, dependency:tree feat(mvn): add Maven (Java) filter module — test, compile, checkstyle:check, dependency:tree Apr 14, 2026
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from b604ddb to 80da844 Compare April 14, 2026 19:16
@mariuszs
mariuszs marked this pull request as ready for review April 14, 2026 19:26
@mariuszs
mariuszs marked this pull request as draft April 15, 2026 20:43
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from 80da844 to 91a6534 Compare April 16, 2026 06:55
@mariuszs
mariuszs changed the base branch from develop to master April 16, 2026 06:55
@mariuszs
mariuszs marked this pull request as ready for review April 16, 2026 07:32
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch 3 times, most recently from 10fd699 to 98907f1 Compare April 16, 2026 12:37
@Ckram

Ckram commented Apr 17, 2026

Copy link
Copy Markdown

@mariuszs could you add support for mvnd (maven daemon) ?

@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from 98907f1 to 781ec7b Compare April 17, 2026 14:15
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
Adds a parallel 'rtk mvnd' subcommand that reuses the mvn filters (test,
compile, checkstyle:check, dependency:tree, passthrough) but invokes the
mvnd binary directly (bypassing mvnw, which the daemon does not use).

- New MvnBinary enum (Mvn auto-detects mvnw; Mvnd always uses mvnd)
- Threaded through run_test/run_compile/run_checkstyle/run_dep_tree/run_other
- Tracking labels keep 'mvn' and 'mvnd' separate in rtk gain
- Discover rule added for mvnd → rtk mvnd rewrites

Addresses review comment on PR rtk-ai#1089.
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request Apr 17, 2026
Adds a parallel 'rtk mvnd' subcommand that reuses the mvn filters (test,
compile, checkstyle:check, dependency:tree, passthrough) but invokes the
mvnd binary directly (bypassing mvnw, which the daemon does not use).

- New MvnBinary enum (Mvn auto-detects mvnw; Mvnd always uses mvnd)
- Threaded through run_test/run_compile/run_checkstyle/run_dep_tree/run_other
- Tracking labels keep 'mvn' and 'mvnd' separate in rtk gain
- Discover rule added for mvnd → rtk mvnd rewrites

Addresses review comment on PR rtk-ai#1089.
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from 864932d to 3d993bf Compare April 17, 2026 18:55
mariuszs added 21 commits May 29, 2026 14:36
Observed on a real Spring Boot project using Google Cloud's private
Maven repo via `artifactregistry-maven-wagon`. Compile-failure logs
carry large amounts of non-actionable chatter that drove savings down
to 41.6% on a 259-line fixture. Adds four detectors:

- INFO_NOISE_PATTERNS:
  * `is present in the local repository, but cached` — dozens of
    ~300-char `[INFO]` lines explaining which remote repos each
    cached artifact would otherwise resolve from. Never needs action.
  * `Initializing Credentials`, `Application Default Credentials`,
    `Refreshing Credentials` — GCP auth lifecycle lines emitted by
    the wagon during download.

- is_mvn_startup_noise:
  * `JUL_LOG_HEADER_RE` — detects java.util.logging header format
    (`Apr 18, 2026 12:19:27 AM com.google.auth.oauth2.X warnY`) so
    that the next-line WARNING body has the right context.
  * `BARE_PLUGIN_WARNING_PREFIXES = ["WARNING: Your application has
    authenticated"]` — body of the GCP end-user-credentials warning.

Fixture: 259-line anonymized capture of the user's real failing build.
Savings: 41.6% -> 86.0% (2419 -> 339 tokens). All compile errors
preserved; BUILD FAILURE + Total time preserved.

Full suite: 1718 passed.
On every successful build, three maven plugins emit one-line
notifications that the user never acts on:

  - maven-enforcer-plugin: one `[INFO] Rule N: <fqcn> passed` line
    per enforced rule (typically RequireMavenVersion, RequireJavaVersion,
    RequirePluginVersions).
  - githook-maven-plugin: `[INFO] Installing commit-msg hook into
    <.git/hooks>` on every build.
  - maven-compiler-plugin: `[INFO] Changes detected - recompiling the
    module!` immediately before the real compile step.

Adds ENFORCER_RULE_PASSED_RE (regex, anchored and requires the trailing
` passed`) and substring patterns for the other two. Saves 3–8 lines on
a typical build. On the 259-line artifactregistry fixture, savings go
from 86.0% → 86.8% (2419 → 319 tokens, 64 lines). Compile errors and
`BUILD FAILURE` still preserved.

Full suite: 1719 passed.
Three large fixtures were padded with redundant noise that did not
strengthen any assertion — the filter strips a *pattern*, not a count.
Cut the repetitions while preserving every signal the assertions check:

- mvn_compile_artifactregistry.txt: 259 -> 107 (-58%)
- mvn_test_compile_failure.txt:     180 -> 52  (-71%)
- mvn_dep_tree_beacon.txt:          652 -> 281 (-57%)

Beacon snapshot regenerated (28 direct deps with intact transitive
counts). All three preserve their savings thresholds (>=80%, >=60%).

Renamed PR-tagged fixtures to behavior-based names so their purpose
stays clear once the PR number is forgotten:

- mvn_pr782_*_raw.txt        -> mvn_{compile,test}_reactor_*.txt
- mvn_pr1241_compile_pgp_*   -> mvn_compile_pgp_multimodule.txt
- mvn_pr1241_test_failure_*  -> mvn_test_failure_stack_isolation.txt

Test fn names updated to match. PR provenance moved into module-level
comments. cargo test --all: 1719 passed, 6 ignored.
…l review

Two HIGH findings from Codex adversarial review on PR rtk-ai#1089:

1) Reactor / `-pl <module>` runs lost failure details
   `enrich_with_reports` only probed `<cwd>/target/{surefire,failsafe}-reports`,
   so reactor builds and `mvn -pl <module>` from the repo root silently
   fell back to "no XML reports found" despite fresh per-module reports
   existing under `<module>/target/...`.

   Added `discover_report_dirs()` walking depth-1 module dirs (skipping
   `.*`, `target`, `src`, `node_modules`, `build`, `out`) and a
   `collect_reports()` merger that aggregates SurefireResults across
   every module that produced output.

2) Forked-VM crashes / surefire aborts reported as `0 passed`
   When the parser entered Testing but BUILD FAILURE arrived before a
   `Results:` block (forked-VM crash, surefire timeout, plugin abort),
   `cumulative` stayed at zero and the success branch emitted a
   synthetic `0 passed` summary — silently hiding a hard failure.

   Added a guard: when `BUILD FAILURE` is present and no failure was
   parsed, fall back to `filter_mvn_compile` so the actual error block
   surfaces to the user.

Tests:
- enrich_reactor_finds_per_module_reports — depth-1 module walk
- enrich_reactor_real_world_anliksim_multi_module — real fixture from
  anliksim/maven-multi-project-example (4-module reactor, module1 fails,
  module2 SKIPPED) using full pipeline (filter -> enrich)
- enrich_reactor_skips_dot_dirs_and_node_modules — walker boundary
- test_forked_vm_crash_never_emits_synthetic_pass — surefire booter
  exit-137 scenario

cargo test --all: 1723 passed, 6 ignored.
The reactor multi-module fixtures landed with personal paths
(`/home/user/...`) and a project-specific package name
(`anliksim`). Anonymize and compact:

- anliksim -> com.example.app (package + groupId)
- /workspace/example-project/...  -> /workspace/example-project/

Compaction (filter still asserts the same signal — class.method,
ComparisonFailure message, BUILD FAILURE, no-reports-hint absent):

- mvn_test_reactor_module_failure.txt:    130 -> 56  (-57%)
  Drops repeated WARNING boilerplate, "Loaded N auto-discovered
  prefixes" repeats, BoM "Copying" pom lines, "skip non existing
  resourceDirectory" trivia, and the 30-line JUnit reflection
  stack trace (5-frame essence kept).

- TEST-com.example.app.SpeakerTest.xml:   ~70 -> 13 (-81%)
- TEST-com.example.app.AppTest.xml:       ~67 -> 4  (-94%)
  Drops the surefire <properties> block (60+ properties full of
  absolute paths and personal info — the parser never reads them).

cargo test --all: 1723 passed, 6 ignored.
XML reports are authoritative (stack trace, captured output), so strip
the text-filter's `Failures:` block whenever surefire/failsafe XML has
failures. Fallback path (XML missing) still surfaces the text block so
users keep context from stdout parsing.
When XML is missing and the text parser is the only failure source,
its output now matches the XML-enriched format:

1. Shorten exception FQN on the first detail line
   (`org.junit.ComparisonFailure:` -> `ComparisonFailure:`) via
   `shorten_exception_header`, mirroring `failure_kind_label`'s
   `rsplit('.').next()` logic.

2. Drop non-app stack frames when pom groupId is known
   (`app_packages` threaded through `filter_mvn_tests_with_goal`).
   `org.junit.Assert.*`, `org.hamcrest.*`, and similar assertion-lib
   frames were leaking through the legacy whitelist — now gated by
   `is_framework_frame_ext` which also rejects any `at <pkg>...`
   frame not in `app_packages`.

Empty `app_packages` falls back to the legacy whitelist — no
regression for fixtures and callers that do not detect a groupId.
Upstream introduced src/cmds/jvm/ (gradlew). Consolidate the Maven filter
(mvn_cmd, pom_groupid, stack_trace, surefire_reports) under the same jvm/
umbrella so the module layout matches upstream.

- move src/cmds/java/* -> src/cmds/jvm/*
- crate::cmds::java:: -> crate::cmds::jvm::
- rename insta snapshots __java__ -> __jvm__ and fix source: headers
- drop `pub mod java;` (jvm/mod.rs automod already covers the dir)
- docs: src/cmds README, jvm README title + gradlew note, module map
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
Adds a parallel 'rtk mvnd' subcommand that reuses the mvn filters (test,
compile, checkstyle:check, dependency:tree, passthrough) but invokes the
mvnd binary directly (bypassing mvnw, which the daemon does not use).

- New MvnBinary enum (Mvn auto-detects mvnw; Mvnd always uses mvnd)
- Threaded through run_test/run_compile/run_checkstyle/run_dep_tree/run_other
- Tracking labels keep 'mvn' and 'mvnd' separate in rtk gain
- Discover rule added for mvnd → rtk mvnd rewrites

Addresses review comment on PR rtk-ai#1089.
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from f79f814 to 6b203cb Compare May 29, 2026 12:41
mariuszs added a commit to mariuszs/rtk-java that referenced this pull request May 29, 2026
…l review

Two HIGH findings from Codex adversarial review on PR rtk-ai#1089:

1) Reactor / `-pl <module>` runs lost failure details
   `enrich_with_reports` only probed `<cwd>/target/{surefire,failsafe}-reports`,
   so reactor builds and `mvn -pl <module>` from the repo root silently
   fell back to "no XML reports found" despite fresh per-module reports
   existing under `<module>/target/...`.

   Added `discover_report_dirs()` walking depth-1 module dirs (skipping
   `.*`, `target`, `src`, `node_modules`, `build`, `out`) and a
   `collect_reports()` merger that aggregates SurefireResults across
   every module that produced output.

2) Forked-VM crashes / surefire aborts reported as `0 passed`
   When the parser entered Testing but BUILD FAILURE arrived before a
   `Results:` block (forked-VM crash, surefire timeout, plugin abort),
   `cumulative` stayed at zero and the success branch emitted a
   synthetic `0 passed` summary — silently hiding a hard failure.

   Added a guard: when `BUILD FAILURE` is present and no failure was
   parsed, fall back to `filter_mvn_compile` so the actual error block
   surfaces to the user.

Tests:
- enrich_reactor_finds_per_module_reports — depth-1 module walk
- enrich_reactor_real_world_anliksim_multi_module — real fixture from
  anliksim/maven-multi-project-example (4-module reactor, module1 fails,
  module2 SKIPPED) using full pipeline (filter -> enrich)
- enrich_reactor_skips_dot_dirs_and_node_modules — walker boundary
- test_forked_vm_crash_never_emits_synthetic_pass — surefire booter
  exit-137 scenario

cargo test --all: 1723 passed, 6 ignored.
The old prose described the pre-multi-goal Clap sub-enum with
external_subcommand routing, which no longer exists. Describe the actual
dispatch -> route_goal flow (0 goals passthrough, 1 goal dedicated
filter, >=2 goals multi-goal aggregator).
@mariuszs
mariuszs force-pushed the feat/mvn-rust-module branch from 6de98bc to a72254a Compare May 29, 2026 18:24
audichuang added a commit to audichuang/rtk that referenced this pull request Jun 8, 2026
…tk-ai#1956)

Deep-compared our PR rtk-ai#1089-based mvn module against upstream's newly-merged
PR rtk-ai#1956. Our module remains the richer superset (mvnd/checkstyle/dependency:tree/
clean + Surefire/Failsafe XML enrichment); 8 of 11 dimensions were equal-or-better
and deliberately NOT absorbed. Three confirmed upstream advantages are absorbed
here, scoped to avoid regressing our extra features:

1. Single-goal install/package/deploy/integration-test routing (was 0% savings).
   route_goal now maps them to GoalRouting::TestLike; dispatch runs them through
   run_tests_like with the user's LITERAL goal preserved (NOT rerouted to `verify`,
   which would drop the .m2 install / deploy side-effects). run_tests_like takes a
   &str goal; the TestLikeGoal enum is removed.

2. English-footer guard (has_english_footer, ported from upstream). Non-English
   locales (e.g. French `BUILD ÉCHEC`) and no-POM runs lack a BUILD SUCCESS/FAILURE
   footer; without the guard a failed French `mvn clean` was silently mis-reported
   as "nothing to clean". Guard applied at the single-goal wrapper layer only
   (run_tests_like closure + filter_mvn_clean), never on the shared multi-goal
   cores which receive footerless segment slices.

3. Surefire 2.x single-dash close-line counting. The per-class gate excluded only
   the 3.x ` -- in ` form, so a 2.x ` - in ` multi-class run undercounted to the
   last class (e.g. 5 instead of 35). Gate now excludes both via ` - in `.

Fixtures mvn_install_slice.txt + mvn_locale_fr.txt copied from upstream; a faithful
Surefire 2.22.x multi-class fixture added for rtk-ai#3. Gate green: fmt + clippy +
2224 tests (4 new).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
audichuang added a commit to audichuang/rtk that referenced this pull request Jun 8, 2026
This is a fork that diverges from rtk-ai/rtk (notably the richer PR rtk-ai#1089
mvn/mvnd module, which upstream rejected for its own PR rtk-ai#1956). Record an
explicit per-commit disposition (absorbed / cherry-picked / skipped+reason)
so future syncs never re-triage or miss a commit.

- Ledger covers upstream 0a630fe..047f454 (triaged 2026-06-08).
- Documents the mvn decision (keep ours, absorb 3 wins, 8 deliberately not),
  the sync base, remotes, and a re-sync runbook.
- Link from CLAUDE.md mvn/mvnd section; warns never to blind-merge upstream.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The mvn/mvnd routing regex required the lifecycle goal to immediately
follow the binary, so global options placed before the goal broke the
rewrite: `./mvnw -q test`, `mvn -DskipTests package`, `mvn -pl core verify`
all fell through to the raw, unfiltered command.

Insert `(?:\S+\s+)*` between the binary and the goal so any leading
option tokens are skipped. Also make the `./` prefix group non-capturing
so the goal becomes capture group 1 — this fixes the per-goal savings
lookup (MVN_SUBCMD_SAVINGS was never consulted because group 1 used to
capture the `./` prefix instead of the goal).
@mariuszs mariuszs closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants