I've got a gradle based ktor project, and I run it...
# intellij
a
I've got a gradle based ktor project, and I run it for testing from the gradle
run
task of the module. I have a run configuration for that gradle task saved to the project file, and I want that config to always run in development mode. So I added the VM option to do so, and seem to be running into a problem where my program doesn't actually have these system props set at run time.
I see for sure that it is running with the proper command:
Copy code
12:21:46 AM: Executing 'run -Dio.ktor.development=true'...
But in my code, when I attempt to query anything I set in the VM options, it's never set:
Copy code
println(System.getProperty("io.ktor.development")) // This always returns false
I was thinking maybe gradle ends up spawning another process or something that has different VM args? But I can't for the life of me find anything about that.
t
Sounds like you're in the wrong JVM
-D you use for
run
is for Gradle, so the println will ONLY work in build.gradle.kts
this is micronaut, but the
org.gradle.application
plugin's
run
task is in play in both
a
this is sort of along the lines of what I thought was going on. The weird thing is that if I search for how to set system parameters for a program in intelliJ, I find numerous posts and articles indicating that the way I'm doing it is the correct way for my program to have a system property set.
this seems crazy to me there isn't a better way to do this
sure seems like the only way is by hard coding it. But this point of doing it from a run-config is that I can configure it
I dont want the default to be debug mode, i'd really like this run config to be the way I run in debug mode
t
Copy code
if (System.getProperty("idea.version").isNotEmpty()) {
    tasks.named<Exec>("run") { systemProperty("io.ktor.development", true) }
}