https://kotlinlang.org logo
#gradle
Title
# gradle
e

edwinRNDR

10/11/2023, 1:37 PM
v

Vampire

10/11/2023, 2:09 PM
What does the IDE say the type is in that closure?
Seems to be
KotlinJvmRunDsl
which only allows to configure main class, arguments and classpath, so probably not from there. But you can probably directly configure the carrier task like
Copy code
val jvmRun by tasks.existing(JavaExec::class) {
    workingDir = ...
}
e

edwinRNDR

10/11/2023, 2:33 PM
That gives me
Task with name 'jvmRun' not found in project
I placed it in an
afterEvaluate {}
inside
jvm().mainRun{ }
and that seems to do the job
v

Vampire

10/11/2023, 2:41 PM
afterEvaluate
is evil, don't use it if avoidable. It's main effect is introducing timing problems, ordering problems, and race conditions, while usually just doing symptom treatment.
Copy code
tasks.withType<JavaExec>().matching { it.name == "jvmRun" }.configureEach { workingDir = ... }
e

edwinRNDR

10/11/2023, 2:42 PM
I am not surprised
this works! Thanks @Vampire!
👌 1
3 Views