11/*
2- * Copyright 2012-2024 the original author or authors.
2+ * Copyright 2012-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2222import org .gradle .api .services .BuildServiceParameters ;
2323
2424/**
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.
2729 *
2830 * @author Andy Wilkinson
2931 */
@@ -32,7 +34,16 @@ abstract class DockerTestBuildService implements BuildService<BuildServiceParame
3234 static Provider <DockerTestBuildService > registerIfNecessary (Project project ) {
3335 return project .getGradle ()
3436 .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 ());
3647 }
3748
3849}
0 commit comments