Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does gradle continuous build support SpringBoot?

When I try to run build with gradle with the -t flag:

./gradlew clean build -x test -t

I get prompt line:

Waiting for changes to input files of tasks... (ctrl-d to exit)

but when I try it with bootRun command it doesn't work/appear:

./gradlew clean bootRun -t

Does it work with Spring Boot? (I know about Spring dev tools plugin - 1.3 is not released yet)

like image 201
kasiacode Avatar asked Jul 20 '15 08:07

kasiacode


2 Answers

andy-wilkinson is correct in his answer : gradle bootRun never completes because some applications run indefinitely. Its well documented in this issue in the grails project.

I've found a way to force bootRun to live reload the application from the command line. The key items here are the gradle daemon and the spring-boot-devtools package.

To get it to live reload you need to have 2 terminals open.

  1. gradle build --continuous

    • build --continuous will keep satisfying the initial build request until stopped
    • gradle build --continuous --quiet & 2>1 >/dev/null runs in the background, but you would miss the important build warnings/errors. gradle --stop to stop watching.
  2. gradle bootRun

    • Bootrun starts with spring-boot-devtools on classpath, which will detect changes and restart application.
like image 149
Stefan Crain Avatar answered Feb 22 '23 04:02

Stefan Crain


It depends on the nature of your Spring Boot application. If you app typically runs and then exits then continuous build will work. However if your app typically stays alive indefinitely, for example because it's a web app that handles HTTP requests, then it won't work. In the latter case the bootRun task never completes so Gradle doesn't know that it's time to start watching for changes.

like image 21
Andy Wilkinson Avatar answered Feb 22 '23 04:02

Andy Wilkinson