1616import java .nio .file .Path ;
1717import java .util .Arrays ;
1818import java .util .List ;
19+ import java .util .regex .Matcher ;
20+ import java .util .regex .Pattern ;
1921import java .util .stream .Collectors ;
2022import java .util .stream .Stream ;
2123
2527@ SuppressWarnings ("ConstantConditions" )
2628class ModulePluginSmokeTest {
2729 private static final Logger LOGGER = Logging .getLogger (ModulePluginSmokeTest .class );
30+ private static final Pattern SEMANTIC_VERSION = Pattern .compile ("(?<major>\\ d+)\\ .(?<minor>\\ d+).(?<patch>\\ d+)" );
2831
2932 private List <File > pluginClasspath ;
3033
3134 @ SuppressWarnings ("unused" )
3235 private enum GradleVersion {
3336 v5_1 , v5_6 ,
3437 v6_3 , v6_4_1 , v6_5_1 , v6_8_3 ,
35- v7_0 , v7_6_4
38+ v7_0 , v7_6_4 ,
39+ v8_0 , v8_6
3640 ;
3741
3842 @ Override
@@ -52,11 +56,16 @@ void before() throws IOException {
5256
5357 @ CartesianTest (name = "smokeTest({arguments})" )
5458 void smokeTest (
55- @ CartesianTest .Values (strings = {"test-project" , "test-project-kotlin-pre-1-7" , "test-project-kotlin" , "test-project-groovy" }) String projectName ,
59+ @ CartesianTest .Values (strings = {
60+ "test-project" ,
61+ "test-project-kotlin-pre-1-7" ,
62+ "test-project-kotlin" ,
63+ "test-project-groovy"
64+ }) String projectName ,
5665 @ CartesianTest .Enum GradleVersion gradleVersion ) {
5766 LOGGER .lifecycle ("Executing smokeTest of {} with Gradle {}" , projectName , gradleVersion );
5867 assumeTrue (jdkSupported (gradleVersion ));
59- assumeTrue (checkCombination (projectName , gradleVersion ));
68+ assumeTrue (checkKotlinCombination (projectName , gradleVersion ));
6069 var result = GradleRunner .create ()
6170 .withProjectDir (new File (projectName + "/" ))
6271 .withPluginClasspath (pluginClasspath )
@@ -77,11 +86,16 @@ void smokeTest(
7786
7887 @ CartesianTest (name = "smokeTestRun({arguments})" )
7988 void smokeTestRun (
80- @ CartesianTest .Values (strings = {"test-project" , "test-project-kotlin-pre-1-7" , "test-project-kotlin" , "test-project-groovy" }) String projectName ,
89+ @ CartesianTest .Values (strings = {
90+ "test-project" ,
91+ "test-project-kotlin-pre-1-7" ,
92+ "test-project-kotlin" ,
93+ "test-project-groovy"
94+ }) String projectName ,
8195 @ CartesianTest .Enum GradleVersion gradleVersion ) {
8296 LOGGER .lifecycle ("Executing smokeTestRun of {} with Gradle {}" , projectName , gradleVersion );
8397 assumeTrue (jdkSupported (gradleVersion ));
84- assumeTrue (checkCombination (projectName , gradleVersion ));
98+ assumeTrue (checkKotlinCombination (projectName , gradleVersion ));
8599 var writer = new StringWriter (256 );
86100 var result = GradleRunner .create ()
87101 .withProjectDir (new File (projectName + "/" ))
@@ -102,12 +116,20 @@ void smokeTestRun(
102116
103117 @ CartesianTest (name = "smokeTestJunit5({arguments})" )
104118 void smokeTestJunit5 (
105- @ CartesianTest .Values (strings = {"5.4.2/1.4.2" , "5.5.2/1.5.2" , "5.7.1/1.7.1" , "5.10.2/1.10.2" }) String junitVersionPair ,
119+ @ CartesianTest .Values (strings = {
120+ "5.4.2/1.4.2" ,
121+ "5.5.2/1.5.2" ,
122+ "5.7.1/1.7.1" ,
123+ "5.8.0/1.8.0" ,
124+ "5.10.2/1.10.2"
125+ }) String junitVersionPair ,
106126 @ CartesianTest .Enum GradleVersion gradleVersion ) {
107127 LOGGER .lifecycle ("Executing smokeTestJunit5 with junitVersionPair {} and Gradle {}" , junitVersionPair , gradleVersion );
108128 assumeTrue (jdkSupported (gradleVersion ));
109129 var junitVersionParts = junitVersionPair .split ("/" );
110- var junitVersionProperty = String .format ("-PjUnitVersion=%s" , junitVersionParts [0 ]);
130+ final String junitVersion = junitVersionParts [0 ];
131+ assumeTrue (checkJUnitCombination (junitVersion , gradleVersion ));
132+ var junitVersionProperty = String .format ("-PjUnitVersion=%s" , junitVersion );
111133 var junitPlatformVersionProperty = String .format ("-PjUnitPlatformVersion=%s" , junitVersionParts [1 ]);
112134 var result = GradleRunner .create ()
113135 .withProjectDir (new File ("test-project/" ))
@@ -176,11 +198,16 @@ private static void assertExpectedClassFileFormats(
176198
177199 @ CartesianTest (name = "smokeTestDist({arguments})" )
178200 void smokeTestDist (
179- @ CartesianTest .Values (strings = {"test-project" , "test-project-kotlin-pre-1-7" , "test-project-kotlin" , "test-project-groovy" }) String projectName ,
201+ @ CartesianTest .Values (strings = {
202+ "test-project" ,
203+ "test-project-kotlin-pre-1-7" ,
204+ "test-project-kotlin" ,
205+ "test-project-groovy"
206+ }) String projectName ,
180207 @ CartesianTest .Enum GradleVersion gradleVersion ) {
181208 LOGGER .lifecycle ("Executing smokeTestDist of {} with Gradle {}" , projectName , gradleVersion );
182209 assumeTrue (jdkSupported (gradleVersion ));
183- assumeTrue (checkCombination (projectName , gradleVersion ));
210+ assumeTrue (checkKotlinCombination (projectName , gradleVersion ));
184211 var result = GradleRunner .create ()
185212 .withProjectDir (new File (projectName + "/" ))
186213 .withPluginClasspath (pluginClasspath )
@@ -218,11 +245,16 @@ void smokeTestDist(
218245
219246 @ CartesianTest (name = "smokeTestRunDemo({arguments})" )
220247 void smokeTestRunDemo (
221- @ CartesianTest .Values (strings = {"test-project" , "test-project-kotlin-pre-1-7" , "test-project-kotlin" , "test-project-groovy" }) String projectName ,
248+ @ CartesianTest .Values (strings = {
249+ "test-project" ,
250+ "test-project-kotlin-pre-1-7" ,
251+ "test-project-kotlin" ,
252+ "test-project-groovy"
253+ }) String projectName ,
222254 @ CartesianTest .Enum GradleVersion gradleVersion ) {
223255 LOGGER .lifecycle ("Executing smokeTestRunDemo of {} with Gradle {}" , projectName , gradleVersion );
224256 assumeTrue (jdkSupported (gradleVersion ));
225- assumeTrue (checkCombination (projectName , gradleVersion ));
257+ assumeTrue (checkKotlinCombination (projectName , gradleVersion ));
226258 var result = GradleRunner .create ()
227259 .withProjectDir (new File (projectName + "/" ))
228260 .withPluginClasspath (pluginClasspath )
@@ -238,11 +270,16 @@ void smokeTestRunDemo(
238270
239271 @ CartesianTest (name = "smokeTestRunStartScripts({arguments})" )
240272 void smokeTestRunStartScripts (
241- @ CartesianTest .Values (strings = {"test-project" , "test-project-kotlin-pre-1-7" , "test-project-kotlin" , "test-project-groovy" }) String projectName ,
273+ @ CartesianTest .Values (strings = {
274+ "test-project" ,
275+ "test-project-kotlin-pre-1-7" ,
276+ "test-project-kotlin" ,
277+ "test-project-groovy"
278+ }) String projectName ,
242279 @ CartesianTest .Enum GradleVersion gradleVersion ) {
243280 LOGGER .lifecycle ("Executing smokeTestRunScripts of {} with Gradle {}" , projectName , gradleVersion );
244281 assumeTrue (jdkSupported (gradleVersion ));
245- assumeTrue (checkCombination (projectName , gradleVersion ));
282+ assumeTrue (checkKotlinCombination (projectName , gradleVersion ));
246283 var result = GradleRunner .create ()
247284 .withProjectDir (new File (projectName + "/" ))
248285 .withPluginClasspath (pluginClasspath )
@@ -263,7 +300,7 @@ void smokeTestRunStartScripts(
263300
264301 @ Test
265302 void shouldNotCheckInWithCommentedOutVersions () {
266- assertEquals (8 , GradleVersion .values ().length );
303+ assertEquals (10 , GradleVersion .values ().length );
267304 }
268305
269306 private static void assertTasksSuccessful (BuildResult result , String subprojectName , String ... taskNames ) {
@@ -277,16 +314,31 @@ private static void assertOutputDoesNotContain(BuildResult result, String text)
277314 assertFalse (output .contains (text ), "Output should not contain '" + text + "', but was: " + output );
278315 }
279316
280- private static boolean checkCombination (String projectName , GradleVersion gradleVersion ) {
317+ private static boolean checkKotlinCombination (String projectName , GradleVersion gradleVersion ) {
281318 final boolean kotlin_NotSupported = projectName .startsWith ("test-project-kotlin" ) && gradleVersion .toString ().compareTo ("6.4" ) < 0 ;
282- final boolean kotlin1_7_NotSupported = projectName .equals ("test-project-kotlin" ) && gradleVersion .toString ().compareTo ("6.6" ) < 0 ;
283- if (kotlin_NotSupported || kotlin1_7_NotSupported ) {
319+ final boolean kotlinPost1_7_NotSupported = projectName .equals ("test-project-kotlin" ) && gradleVersion .toString ().compareTo ("6.6" ) < 0 ;
320+ final boolean kotlinPre1_7_NotSupported = projectName .equals ("test-project-kotlin-pre-1-7" ) && gradleVersion .toString ().compareTo ("8.0" ) >= 0 ;
321+ if (kotlin_NotSupported || kotlinPost1_7_NotSupported || kotlinPre1_7_NotSupported ) {
284322 LOGGER .lifecycle ("Unsupported combination: {} / Gradle {}. Test skipped" , projectName , gradleVersion );
285323 return false ;
286324 }
287325 return true ;
288326 }
289327
328+ private boolean checkJUnitCombination (final String junitVersion , final GradleVersion gradleVersion ) {
329+ final boolean gradleEighthPlus = gradleVersion .ordinal () >= GradleVersion .v8_0 .ordinal ();
330+ final Matcher m = SEMANTIC_VERSION .matcher (junitVersion );
331+ assumeTrue (m .matches (), "JUnit version not semantic: " + junitVersion );
332+ final boolean junitOlderThan5_8_0 = Integer .parseInt (m .group ("major" )) < 5 ||
333+ (Integer .parseInt (m .group ("major" )) == 5 && Integer .parseInt (m .group ("minor" )) < 8 );
334+
335+ if (gradleEighthPlus && junitOlderThan5_8_0 ) {
336+ LOGGER .lifecycle ("Unsupported JUnit and Gradle combination. Gradle: {}, JUnit: {}: Test skipped" , gradleVersion , junitVersion );
337+ return false ;
338+ }
339+ return true ;
340+ }
341+
290342 private static int javaMajorVersion () {
291343 final String version = System .getProperty ("java.version" );
292344 return Integer .parseInt (version .substring (0 , version .indexOf ("." )));
@@ -301,7 +353,7 @@ private boolean jdkSupported(final GradleVersion gradleVersion) {
301353 case v5_1 :
302354 case v5_6 :
303355 final int major = javaMajorVersion ();
304- if (major >= 14 ) {
356+ if (major > 13 ) {
305357 LOGGER .lifecycle ("Unsupported JDK version '{}' for Gradle 5: Test skipped" , major );
306358 return false ;
307359 }
0 commit comments