How to run a gradle task after bootRun has started up the Springboot app

279 Views Asked by At

I am trying to create a gradle task that will execute a postman collection against a running Spring Boot app. For this to happen the first part of the task has to be that the app is started using gradle bootRun. The problem is that this task never finishes as the server just keeps running.

How could I write this task in a way that will start up the Springboot app, run the postman collection and then stop the app?

tasks.register('runE2Etests') {
    group "E2E Tests"
    doLast {
        exec {
            commandLine 'cmd', '/c', 'gradle bootRun'
        }
        exec {
            commandLine 'cmd', '/c', 'newman run src/main/resources/manualTestData/example.postman_collection.json'
        }
    }
}

I wrote the task above but the task is stuck at gradle bootRun as that is a continuous task and because of this it never goes to the next part of it.

0

There are 0 best solutions below