how we can run two independent tasks parallelly in single gradle project.
Only if you make your build compatible with configuration cache and enable configuration cache: Configuration cache
Configuration cache enables all non-related tasks in all projects to run in parallel, while --parallel
(or its according Gradle property) only allows tasks in different projects to run in parallel.
Hi,
Please let me know any sample project/build.gradle file for implementing worker api for running parallel tasks.
Regards,
Dhruva
That is nothing you can do in your build that uses some task.
The implementation of the task needs to use the worker api to do work in parallel.
Hi @Vampire , thanks for your kind reply, i am new to gradle, i was going through
Developing Parallel Tasks using the Worker API, kindly help me where I need implement the tasks that needs to use worker api, kindly suggest me on this.
Ah, then I got you wrong.
I thought you want to run existing tasks in parallel.
But then I don’t really get your question.
You don’t need a special place to use the Worker API.
Wherever you develop your custom task, be it buildSrc
, and included build, a published standalone build, … doesn’t matter.
Hi, we are planning to run existing tasks in parallel, do I need to create buildSrc directory given in Developing Parallel Tasks using the Worker API.
So, I did not get you wrong, and my answer stays.
You can not run existing tasks in parallel by using the worker API.
You can only use the worker API to do work in parallel when implementing own tasks.
Just as I said before.
And as I also said before, to run existing tasks in parallel, you need to use the configuration cache.
Hi @Vampire , thanks for your kind reply, as suggested by you, we can not run existing bdd tasks in parallel using worker api, in case if we want to run existing tasks in parallel, do we need to split single projects in to subproject/multimodule project, so that we can use worker api, please correct me if I am wrong.
how to run existing tasks in parallel using worker api.
As I said multiple times, you cannot use the worker api to run tasks in parallel you do not program yourself.
The worker api is so that tasks can do their work in parallel, not to run other tasks in parallel.
To run other’s tasks in parallel, you either need to use --parallel
if those tasks are in multiple projects, or the --configuration-cache
to run all tasks in parallel even within one project. (Both can also be enabled by Gradle properties)
Thanks you very much @Vampire, do we have any plugins for running tasks in parallel.
while running gradle --configuration-cache build, getting below message
Option configuration-cache doesn’t accept value ‘build’. Possible values are [OFF, ON, WARN]
Added below line to gradle.properties as well
org.gradle.unsafe.configuration-cache=ON
org.gradle.unsafe.configuration-cache-problems=warn
What should such a plugin do?
Also, to use configuration cache, you should update your Gradle version.
In the version you use, it is not yet stable which could also be related to the error you get when trying to use it.
Hi @Vampire , kindly let me know, which stable version of gradle supports configuration cache
In 8.1 the configuration cache was officially promoted to stable.