11

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)

Opal
  • 81,889
  • 28
  • 189
  • 210
kasiacode
  • 600
  • 7
  • 15

2 Answers2

22

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.
Community
  • 1
  • 1
Stefan Crain
  • 2,010
  • 3
  • 21
  • 22
11

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.

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
  • 3
    Thanks for explanation. In that case, do you know any workarounds for that kind of indefinitely tasks (ex. bootRun)? – kasiacode Jul 20 '15 at 09:48