Is it possible to run two independent gradle tasks from same subproject in parallel?

Viewed 4496

In project on which I work (based on gradle) there is one very big module (gradle subproject). During build on CI two tasks from this subproject are executed sequentially and it leads to significant execution time.

The project uses org.gradle.parallel=true, but when I created simple project to check how independent tasks from same subproject are executed with this property I found out that tasks are executed sequentially.

My question:

Is possible to execute two independent tasks from same gradle subproject in parallel to shorten theirs execution time? (Assuming that they doesn't produce output in same place and don't use any shared state)

1 Answers

From the documentation (see Parallel execution):

Most builds consist of more than one project and some of those projects are usually independent of one another. Yet Gradle will only run one task at a time by default, regardless of the project structure (this will be improved soon). By using the --parallel switch, you can force Gradle to execute tasks in parallel as long as those tasks are in different projects.

I think the most important part here is "as long as those tasks are in different projects": if your two long-running tasks belong to the same subproject you won't be able to make them executed in parallel (not in current Gradle version)

Related