1+ #! /bin/bash
2+
3+ # Strip Maven test boilerplate - show compile errors and test results only
4+ # Usage: ./mvn-test-no-boilerplate.sh [maven test arguments]
5+ #
6+ # Examples:
7+ # ./mvn-test-no-boilerplate.sh -Dtest=RefactorTests
8+ # ./mvn-test-no-boilerplate.sh -Dtest=RefactorTests#testList -Djava.util.logging.ConsoleHandler.level=INFO
9+ # ./mvn-test-no-boilerplate.sh -Dtest=RefactorTests#testList -Djava.util.logging.ConsoleHandler.level=FINER
10+ #
11+ # For running tests in a specific module:
12+ # ./mvn-test-no-boilerplate.sh -pl json-java21-api-tracker -Dtest=CompilerApiLearningTest
13+ #
14+ # The script automatically detects if mvnd is available, otherwise falls back to mvn
15+
16+ # Detect if mvnd is available, otherwise use mvn
17+ if command -v mvnd & > /dev/null; then
18+ MVN_CMD=" mvnd"
19+ else
20+ MVN_CMD=" mvn"
21+ fi
22+
23+ timeout 120 $MVN_CMD test " $@ " 2>&1 | awk '
24+ BEGIN {
25+ scanning_started = 0
26+ compilation_section = 0
27+ test_section = 0
28+ }
29+
30+ # Skip all WARNING lines before project scanning starts
31+ /INFO.*Scanning for projects/ {
32+ scanning_started = 1
33+ print
34+ next
35+ }
36+
37+ # Before scanning starts, skip WARNING lines
38+ !scanning_started && /^WARNING:/ { next }
39+
40+ # Show compilation errors
41+ /COMPILATION ERROR/ { compilation_section = 1 }
42+ /BUILD FAILURE/ && compilation_section { compilation_section = 0 }
43+
44+ # Show test section
45+ /INFO.*T E S T S/ {
46+ test_section = 1
47+ print "-------------------------------------------------------"
48+ print " T E S T S"
49+ print "-------------------------------------------------------"
50+ next
51+ }
52+
53+ # In compilation error section, show everything
54+ compilation_section { print }
55+
56+ # In test section, show everything - let user control logging with -D arguments
57+ test_section {
58+ print
59+ }
60+
61+ # Before test section starts, show important lines only
62+ !test_section && scanning_started {
63+ if (/INFO.*Scanning|INFO.*Building|INFO.*resources|INFO.*compiler|INFO.*surefire|ERROR|FAILURE/) {
64+ print
65+ }
66+ # Show compilation warnings/errors
67+ if (/WARNING.*COMPILATION|ERROR.*/) {
68+ print
69+ }
70+ }
71+ '
0 commit comments