Mikael Ståldal
01/02/2025, 11:00 AMdave
01/02/2025, 11:03 AMmbonnin
01/02/2025, 11:43 AM--continuous
: https://docs.gradle.org/current/userguide/continuous_builds.htmlJames Richardson
01/02/2025, 12:27 PMmbonnin
01/02/2025, 1:09 PMdave
01/02/2025, 1:16 PMTL;DR: Kotlin scripting remains an essential part of the Kotlin infrastructure. We continue to support it in the experimental state, and we are concluding certain experiments and reducing the number of scripting-related technologies that we provide and actively develop.
mbonnin
01/02/2025, 1:22 PMWe will continue to develop the `.main.kts` script type, which is already helpful for simple automation tasks. We have plans to extend its functionality and streamline IDE support.
mbonnin
01/02/2025, 1:23 PMJames Richardson
01/02/2025, 2:13 PMmbonnin
01/02/2025, 2:14 PMmbonnin
01/02/2025, 2:15 PMMikael Ståldal
01/02/2025, 2:40 PMgradle run --continuous
, but I could not get it to work. It seems like others have tried and failed as well:
https://stackoverflow.com/questions/47383516/how-to-auto-reload-hotswap-with-gradle-and-scalaMikael Ståldal
01/02/2025, 2:46 PMgradle build --continuous
seems to work, but doesn't really get all the way towards hot reload 🤷mbonnin
01/02/2025, 2:50 PMI'd tried gradle run --continuous but didn't work because the run task is never-ending and seems like --continuous doesn't start a new build/task unless the previous one has finished.
Welp yea, if it doesn't cancel the previous task, that won't work. Sorry for the red herring.mbonnin
01/02/2025, 2:51 PMMikael Ståldal
01/02/2025, 2:51 PMMikael Ståldal
01/02/2025, 2:53 PMOtherwise using test to test the output, rather than web-page-reloading might work...Well, not really feasible if you are prototyping a UI and want to tweak the look and feel of it.
Mikael Ståldal
01/02/2025, 3:08 PMgradle run
task, or the main class directly), and manually press Ctrl-F5 to re-run. Would be nice if IntelliJ could watch the sources (which I believe it does anyway) and re-run on any change.Andrew O'Hara
01/02/2025, 3:20 PMMikael Ståldal
01/02/2025, 3:22 PMAndrew O'Hara
01/02/2025, 3:24 PMMikael Ståldal
01/02/2025, 3:25 PMAndrew O'Hara
01/02/2025, 3:27 PMService
layer, that can be tested easily. And then build your Views
on top of that, where you can rely on the template hot reloading for prototyping. Could something like that work?Mikael Ståldal
01/02/2025, 3:28 PMAndrew O'Hara
01/02/2025, 3:29 PMAndrew O'Hara
01/02/2025, 3:33 PMJames Richardson
01/02/2025, 3:46 PMJames Richardson
01/02/2025, 3:50 PMMikael Ståldal
01/02/2025, 6:27 PMdave
01/02/2025, 6:28 PMMikael Ståldal
01/02/2025, 6:41 PMJames Richardson
01/02/2025, 7:32 PMJames Richardson
01/02/2025, 7:57 PMdave
01/03/2025, 4:28 PMimplementation("org.http4k:http4k-incubator")
to gradle, then you can run with:
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status
import org.http4k.testing.HotReloadServer
import org.http4k.testing.HttpAppProvider
class HttpApp : HttpAppProvider {
override fun invoke() = { req: Request -> Response(Status.OK).body("my hot reload") }
}
fun main() {
HotReloadServer.http<HttpApp>().start()
}
Under the covers it is watching the source directories and then using gradle to build on changes. It's in no way perfect - multi-module builds almost certainly won't work with it without modifications - but I've just tried it on a simple single module project and it seems to work ok, so maybe it's something we can work on for the future at some point. On failure it spits out the gradle compilation error to the log.
Feel free to have a play and feed back - or even better PR upgrades to it 🙂 ,Mikael Ståldal
01/03/2025, 4:51 PMHttpAppProvider
. It also seems to rebuild twice for each change.dave
01/03/2025, 4:52 PMdave
01/03/2025, 4:54 PMdave
01/03/2025, 4:55 PMMikael Ståldal
01/03/2025, 4:56 PMHttpAppProvider
properly. I got it to work, but with quite convoluted code.dave
01/03/2025, 4:57 PMdave
01/03/2025, 4:58 PMMikael Ståldal
01/03/2025, 4:58 PMdave
01/03/2025, 4:59 PMMikael Ståldal
01/03/2025, 4:59 PMdave
01/03/2025, 5:00 PMMikael Ståldal
01/03/2025, 5:01 PMdave
01/03/2025, 5:02 PMAndrew O'Hara
01/03/2025, 5:03 PMAndrew O'Hara
01/03/2025, 5:03 PMMikael Ståldal
01/03/2025, 5:03 PMdave
01/03/2025, 5:03 PMAndrew O'Hara
01/03/2025, 5:04 PMMikael Ståldal
01/03/2025, 5:04 PMMikael Ståldal
01/03/2025, 5:06 PMdave
01/03/2025, 5:08 PMMikael Ståldal
01/03/2025, 5:22 PMclass HotReload : HttpAppProvider {
val app: HttpHandler = // create your app here
override fun invoke() = app
}
fun main() {
HotReloadServer.http<HotReload>().start()
}
Reinholds Bunde
01/24/2025, 2:20 PM