Skip to content

Commit a65f1d1

Browse files
fix: skip Maven validation plugins that reject generated test files
Maven plugins like Apache Rat, Checkstyle, SpotBugs, PMD, Enforcer, and japicmp reject generated instrumented Java files (e.g. missing license headers). Skip these validation plugins during test compilation and execution since they are irrelevant for generated test code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 380e55b commit a65f1d1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

codeflash/languages/java/test_runner.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
# Allows: letters, digits, underscores, dots, and dollar signs (inner classes)
4646
_VALID_JAVA_CLASS_NAME = re.compile(r"^[a-zA-Z_$][a-zA-Z0-9_$.]*$")
4747

48+
# Skip validation/analysis plugins that reject generated instrumented files
49+
# (e.g. Apache Rat rejects missing license headers, Checkstyle rejects naming, etc.)
50+
_MAVEN_VALIDATION_SKIP_FLAGS = [
51+
"-Drat.skip=true",
52+
"-Dcheckstyle.skip=true",
53+
"-Dspotbugs.skip=true",
54+
"-Dpmd.skip=true",
55+
"-Denforcer.skip=true",
56+
"-Djapicmp.skip=true",
57+
]
58+
4859

4960
def _validate_java_class_name(class_name: str) -> bool:
5061
"""Validate that a string is a valid Java class name.
@@ -493,6 +504,7 @@ def _compile_tests(
493504
return subprocess.CompletedProcess(args=["mvn"], returncode=-1, stdout="", stderr="Maven not found")
494505

495506
cmd = [mvn, "test-compile", "-e", "-B"] # Show errors but not verbose output; -B for batch mode (no ANSI colors)
507+
cmd.extend(_MAVEN_VALIDATION_SKIP_FLAGS)
496508

497509
if test_module:
498510
cmd.extend(["-pl", test_module, "-am"])
@@ -1447,6 +1459,7 @@ def _run_maven_tests(
14471459
# JaCoCo's report goal is bound to the verify phase to get post-test execution data
14481460
maven_goal = "verify" if enable_coverage else "test"
14491461
cmd = [mvn, maven_goal, "-fae", "-B"] # Fail at end to run all tests; -B for batch mode (no ANSI colors)
1462+
cmd.extend(_MAVEN_VALIDATION_SKIP_FLAGS)
14501463

14511464
# Add --add-opens flags for Java 16+ module system compatibility.
14521465
# The codeflash-runtime Serializer uses Kryo which needs reflective access to

0 commit comments

Comments
 (0)