Hi everybody, we have a Gradle 8.11.1 multi-module...
# community-support
i
Hi everybody, we have a Gradle 8.11.1 multi-module project. After I turned on the configuration cache, the build is running tests from different modules in parallel. This is not working for us as each module need to starts docker containers. In parallel the container are fighting for the same network port which breaks tests. I tried to disable parallel execution with
org.gradle.parallel=false
in
gradle.properties
, but the project still builds in parallel. Only after I turned off the the configuration cache, the build is sequential again. Do you have any ideas what is going on?
e
m
With configuration cache tasks always run in parallel,
org.gradle.parallel
has no effect. In order to limit parallelism, you can use a build service with
maxParallelUsages = 1
. You can then connect it to test tasks with
Task.usesService()
. Its implementation can be empty.
e
you could potentially use
--max-workers=1
but that will slow your whole build down
build services are definitely the right solution for shared resources (like ports)
although can you not run your docker containers with private network namespaces?
i
@Mikhail Lopatkin thanks, using the service is probably the simplest solution for me. @ephemient, I don't think docker networks can help me in my case. Tests are running in Gradle on the host and containers are just the infra like Postges.
m
Please be aware that for a multi-module project it is better to register the build service in a settings plugin or in the root project, to avoid classpath shenanigans.
i
Setting "org.gradle.workers.max=1" turned out to be even easier for us as our project wasn't build in parallel previously. But I still want to play around with the the services because not all our tests set require the shared resources. So some stuff can really run in parallel.
t
I don't think docker networks can help me in my case. Tests are running in Gradle on the host and containers are just the infra like Postges.
No, but you probably could use different (dynamic) ports so they can run in parallel. (ideally let Docker pick a dynamic port, i.e. use
-p 5432
rather than
-p 127.0.0.1:5432:5432
if using the command line, then ask docker for the port it picked, e.g. using `docker inspect`: https://docs.docker.com/reference/cli/docker/inspect/#list-all-port-bindings)
i
Guys, there is probably a solution how to solve the issue of creating multiple non-conflicting infras but they is not my concern right now. Thanks for trying to help.
@Mikhail Lopatkin thanks, shared service are working like charm!