How to run continous build in parralel with reloading run

I have project - https://github.com/gintsgints/hello-ktor-api
ktor has watch feature within run, so when I start it with - gradlew run all recompiled code get hotreplaced with new one.
To recompile I start another command in another console gradlew -t build for continous build.

I imagine it should be possible to run both tasks in parrallel.
Is it possible to make it so, and if yes then how?

PS. gradlew -t build run does not work. It stuck with run option.

I am not familiar with ktor, but I am wondering why you need to call run in the first place after a change. Doesn’t that just restart the ktor application, which would defeat the purposes of having the application watch for changes in the first place? :face_with_raised_eyebrow: I would imagine that if ktor can correctly pick up changes to your class files, it would be enough to just run gradlew -t classes (assuming you don’t want to re-run unit tests on all code changes).

If the watch functionality in ktor doesn’t work, you could probably also just rely purely on gradle through gradlew -t run; it should re-compile any changes you make and restart the application. Does this not work either?

I do not need call run after change. I need to start it once, and after that, KTOR picks up all compiled class changes. So I need two paralel continous tasks - one - for recompiling classes after source change, other, ‘run’, to keep running api and update as soon as prevous has updated classes.

Ah, I see. Sorry, still a bit low on coffee today.

I imagine that the run task already runs the embedded web server without existing, so you shouldn’t put that in with the -t option as that means it will just re-execute it on changes.

Is it a problem to execute the two tasks in two different consoles, or is it just to simplify things that you like to execute the two tasks in one go, but only have one of them run in continuous mode? If that is what you want, you can probably make a custom run task that does not have declared inputs on other tasks or files that may change, which would cause it to run again. But I am not sure if that accomplishes much. Other than that, I am out of ideas :slight_smile:

Exactly, that is what I want. But with specific, that both tasks are continous.