1
1
/*
2
- * Copyright 2012-2024 the original author or authors.
2
+ * Copyright 2012-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import org .gradle .api .services .BuildServiceParameters ;
23
23
24
24
/**
25
- * Build service for Docker-based tests. Configured to only allow serial execution,
26
- * thereby ensuring that Docker-based tests do not run in parallel.
25
+ * Build service for Docker-based tests. The maximum number of {@code dockerTest} tasks
26
+ * that can run in parallel can be configured using
27
+ * {@code org.springframework.boot.dockertest.max-parallel-tasks}. By default, only a
28
+ * single {@code dockerTest} task will run at a time.
27
29
*
28
30
* @author Andy Wilkinson
29
31
*/
@@ -32,7 +34,16 @@ abstract class DockerTestBuildService implements BuildService<BuildServiceParame
32
34
static Provider <DockerTestBuildService > registerIfNecessary (Project project ) {
33
35
return project .getGradle ()
34
36
.getSharedServices ()
35
- .registerIfAbsent ("dockerTest" , DockerTestBuildService .class , (spec ) -> spec .getMaxParallelUsages ().set (1 ));
37
+ .registerIfAbsent ("dockerTest" , DockerTestBuildService .class ,
38
+ (spec ) -> spec .getMaxParallelUsages ().set (maxParallelTasks (project )));
39
+ }
40
+
41
+ private static int maxParallelTasks (Project project ) {
42
+ Object property = project .findProperty ("org.springframework.boot.dockertest.max-parallel-tasks" );
43
+ if (property == null ) {
44
+ return 1 ;
45
+ }
46
+ return Integer .parseInt (property .toString ());
36
47
}
37
48
38
49
}
0 commit comments