From 7e6fee8714396cb79d81aaecae5f5cd69e178d09 Mon Sep 17 00:00:00 2001 From: Oliver Erhart <8238759+thunderhook@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:40:04 +0100 Subject: [PATCH] #1064 Provide a switch to turn off CheckStyle on generated test sources --- .../mapstruct/ap/testutil/runner/CompilingExtension.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java index 7c47d2a2e..95874e4b3 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java @@ -182,11 +182,15 @@ abstract class CompilingExtension implements BeforeEachCallback { assertDiagnostics( actualResult.getDiagnostics(), expectedResult.getDiagnostics() ); assertNotes( actualResult.getNotes(), expectedResult.getNotes() ); - if ( !findAnnotation( testClass, DisableCheckstyle.class ).isPresent() ) { + if ( !findAnnotation( testClass, DisableCheckstyle.class ).isPresent() && !skipCheckstyleBySystemProperty() ) { assertCheckstyleRules(); } } + private static boolean skipCheckstyleBySystemProperty() { + return Boolean.parseBoolean( System.getProperty( "checkstyle.skip" ) ); + } + private void assertCheckstyleRules() throws Exception { if ( sourceOutputDir != null ) { Properties properties = new Properties();