16
16
17
17
package org .springframework .build ;
18
18
19
+ import java .util .Map ;
20
+
19
21
import org .gradle .api .Project ;
20
22
import org .gradle .api .plugins .JavaBasePlugin ;
21
23
import org .gradle .api .tasks .testing .Test ;
@@ -41,11 +43,36 @@ void apply(Project project) {
41
43
42
44
private void configureTestConventions (Project project ) {
43
45
project .getTasks ().withType (Test .class ,
44
- test -> project .getPlugins ().withType (TestRetryPlugin .class , testRetryPlugin -> {
45
- TestRetryTaskExtension testRetry = test .getExtensions ().getByType (TestRetryTaskExtension .class );
46
- testRetry .getFailOnPassedAfterRetry ().set (true );
47
- testRetry .getMaxRetries ().set (isCi () ? 3 : 0 );
48
- }));
46
+ test -> {
47
+ configureTests (project , test );
48
+ configureTestRetryPlugin (project , test );
49
+ });
50
+ }
51
+
52
+ private void configureTests (Project project , Test test ) {
53
+ test .useJUnitPlatform ();
54
+ test .include ("**/*Tests.class" , "**/*Test.class" );
55
+ test .setSystemProperties (Map .of (
56
+ "java.awt.headless" , "true" ,
57
+ "io.netty.leakDetection.level" , "paranoid" ,
58
+ "io.netty5.leakDetectionLevel" , "paranoid" ,
59
+ "io.netty5.leakDetection.targetRecords" , "32" ,
60
+ "io.netty5.buffer.lifecycleTracingEnabled" , "true"
61
+ ));
62
+ if (project .hasProperty ("testGroups" )) {
63
+ test .systemProperty ("testGroups" , project .getProperties ().get ("testGroups" ));
64
+ }
65
+ test .jvmArgs ("--add-opens=java.base/java.lang=ALL-UNNAMED" ,
66
+ "--add-opens=java.base/java.util=ALL-UNNAMED" ,
67
+ "-Djava.locale.providers=COMPAT" );
68
+ }
69
+
70
+ private void configureTestRetryPlugin (Project project , Test test ) {
71
+ project .getPlugins ().withType (TestRetryPlugin .class , testRetryPlugin -> {
72
+ TestRetryTaskExtension testRetry = test .getExtensions ().getByType (TestRetryTaskExtension .class );
73
+ testRetry .getFailOnPassedAfterRetry ().set (true );
74
+ testRetry .getMaxRetries ().set (isCi () ? 3 : 0 );
75
+ });
49
76
}
50
77
51
78
private boolean isCi () {
0 commit comments