Fergus Hewson
09/16/2024, 8:29 AMtasks.withType<KotlinJvmRun> {
jvmArgs = "-DmainClass=MainKt"
}
Vampire
09/16/2024, 8:54 AMtasks.withType<...> { ... }
is bad anyway as you break task-configuration avoidance, but instead tasks.withType<...>.configureEach { ... }
should be used.
Besides that, if you shouldn't use KotlinJvmRun
, you should probably instead use its supertype JavaExec
.
Besides that with both you configure all tasks of that type, so you should probably more do tasks.withType<JavaExec>().named { it == "desktopRun" }.configureEach { ... }
Fergus Hewson
09/16/2024, 9:39 AMVampire
09/16/2024, 9:58 AMFergus Hewson
09/16/2024, 10:00 AMVampire
09/16/2024, 10:02 AMFergus Hewson
09/16/2024, 10:05 AMtasks.withType<JavaExec>().named { it == "desktopRun" }.configureEach {
systemProperty("mainClass", "MainKt")
Vampire
09/16/2024, 10:06 AMVampire
09/16/2024, 10:07 AMdesktopRun
just that you now use the DSLVampire
09/16/2024, 10:07 AMVampire
09/16/2024, 10:08 AMSystem.setProperty
in the configureEach
, even if that works somehow, it will not really do what you want and just make your build flakyFergus Hewson
09/16/2024, 10:13 AMFergus Hewson
09/16/2024, 10:14 AMVampire
09/16/2024, 10:17 AMVampire
09/16/2024, 10:17 AMVampire
09/16/2024, 10:17 AMFergus Hewson
09/16/2024, 10:18 AMVampire
09/16/2024, 10:18 AMFergus Hewson
09/16/2024, 10:20 AMVampire
09/16/2024, 10:20 AMdesktopRun
task is configured.
For example imagine that you also have a desktopRun2
task where you need a different value, so you do the same non-sense.
Then you run Gradle like ./gradlew desktopRun desktopRun2
.
Both task get configured.
The System property is set to the value that was configured while configuring the second task and is like that for the whole Gradle invocation.Fergus Hewson
09/16/2024, 10:30 AMFergus Hewson
09/16/2024, 10:44 AM