Nick Wills
Nick Wills

Reputation: 1138

Mutli-Project Gradle - Run bootRun task For Each Child Project

IDE: Spring Tool Suite 4
Framework: Spring Boot
Gradle: v6

I have created a multi-project gradle build consisting of 3 child projects A, B and C. I want to create a custom task in the root build.gradle to achieve the following Running the custom task will
1) Execute the child project A's bootRun task.
2) Then after few seconds, execute child Project B and C's bootRun task

*bootRun is a task that run the project as spring boot application

Note that child project A is a server, so it will keep running in the background, whereas child project B and C are the client to the project A (server).

Question is how to write such custom task to achieve the above?

Upvotes: 0

Views: 1398

Answers (2)

smac89
smac89

Reputation: 43234

If you don't need the "waiting" part, then this is easily achievable by creating a task that depends on all the other tasks you want to run.

task startBootStack(type: GradleBuild) {
    tasks = [
      ':A:bootRun',
      ':B:bootRun',
      ':C:bootRun'
    ]
}

Execute with gradle --parallel startBootStack

Upvotes: 1

kaushik
kaushik

Reputation: 2512

In the comment to the answer by smac89, you have mentioned that "But I would like to achieve configuring the parallel into the build.gradle file". In that case, you can create

gradle.properties

file in the root of the project directory and add the following to it.

org.gradle.parallel=true

Upvotes: 1

Related Questions