This should work right? `./gradlew -Dio.ktor.devel...
# ktor
a
This should work right?
./gradlew -Dio.ktor.development=true run
with this Gradle application configuration:
Copy code
application {
    mainClass.set("nl.helicotech.app.AppKt")
}
Because I am getting the following:
[main] INFO ktor.application - Autoreload is disabled because the development mode is off.
But this works:
Copy code
application {
    mainClass.set("nl.helicotech.app.AppKt")
    applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
}
Via the IntelliJ Run Configuration is also not working
Following the gettings tarted guide and creating a new Ktor project in IntelliJ it also doesn't work. So either I am dumb and missing something completely obvious or something is wrong 😉
I figured it out... I am dumb, as expected. In the docs it states:
If you run your application using a Gradle task, you can pass io.ktor.development to the applicationDefaultJvmArgs property in a *build.gradle(.kts)* file.
However, I still don’t know why I can’t get it to work when I don’t run it via a Gradle task
a
As far as I understand, the VM options cannot be directly passed to the application via CLI while using the
run
task. You can define a property that could determine if the development mode is on:
Copy code
application {
    // ... 
    if (hasProperty("dev")) {
        applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
    }
}
The usage:
Copy code
./gradlew run -Pdev