This message was deleted.
# community-support
s
This message was deleted.
a
does the HTTP service have a health endpoint you can use to check if it's available inside of a Gradle task?
I'd try creating a ValueSource to check the server status, and registering it as a task input for
:b:run
i
does the HTTP service have a health endpoint
I can add a
/ping
endpoint easily, if that's what you mean.
I'm not sure how ValueSource helps, here?
a
yeah, that's right I'd add a health endpoint. I'd use a ValueSource to encapsulate the complex logic of sending an HTTP request to the health endpoint, parsing the result, determining when the server restarted, and providing it as a task input in the form of
Copy code
val webServiceRestartDate: Provider<String>
It doesn't matter if it's String or LocalDateTime - all that matters is that at some point it will change when the server restarts and it's registered as an input for
:subproject-b:run
. And then that provider can be registered as an input for task
:subproject-a:run
, so when you run
./gradlew run
in continuous mode then if you edit files in subproject-b this will trigger a server restart, and then the ValueSource will change, and then Gradle will re-run
:subproject-b:run
but that's entirely theoretical - maybe it doesn't work like that in practice 🙃
i
It's a good attempt, but I don't think it'll work: Gradle only starts checking inputs after the task has finished, and
Exec
tasks never finish, so it'll never notice that the
ValueSource
has changed
a
Hmmm I don't quite follow, sorry. What do you mean by Exec tasks never finish? :)
i
I mean, if I start a web server, Gradle continuous won't do anything until the server stops, even if the sources change
a
hmm okay, dang it
I did find an inconsistency in the docs - it turns out continuous mode ignores changes to non-file based inputs https://github.com/gradle/gradle/issues/26252
so you have two projects,
:a
and
:b
. Does
:a
use the Application plugin to create a zip with an executable script?
i
Yes
a
and it would be okay if you ran
./gradlew :b:run --continuous
, just so long as if you made any changes to any files in
:a
then
:b:run
would restart?
which would work, for example, if both
:a
and
:b
were Java projects, and you just had
runtimeOnly(project(":a"))
in project
:b
- because that would trigger a recompile of
:b
?
i
It wouldn't, because Gradle only checks inputs when
:b:run
ends. If I stopped the server myself, Gradle would notice the inputs have changed, and restart it, but as long as I don't stop it myself nothing happens.
a
I thought that when running with
--continuous
then Gradle would always check input files, not just when a task ends?
i
AFAIK, the algo is • configure the project • run the tasks • when everything is over, start watching the inputs; when they change, restart everything
At least, I've never seen continuous mode kill a running process, I've always had to stop them
a
I've got a multimodule Kotlin Multiplatform project, and in one project I run the task
jsBrowserDevelopmentRun
(or whatever the name is), and if I edit files in another subproject (that's a dependency) it will restart the task - is that different to what you're doing?
i
jsBrowserDevelopmentRun
is a weird task because it does, indeed, notice the continuous rebuild and somehow restart itself. From what I've read from other people, the Kotlin JS plugin does very strange things to make it work, but I don't really understand what
a
ahh okay, so my understanding is skewed, because my only experience with
--continuous
is with KMP JS