Arjan van Wieringen (avwie)
10/19/2024, 3:20 PMapplication plugin installed. Is it possible to add a new task runDev that uses the normal run task, but passes command-line variables to the Kotlin/Java main function?Arjan van Wieringen (avwie)
10/19/2024, 3:36 PMtasks.register("runDev") {
group = "application"
val originalTask = tasks.getByName("run") as JavaExec
originalTask.args("-config=application-dev.conf")
dependsOn(originalTask)
}Sergej Koščejev
10/19/2024, 6:44 PMgradle run runDev then it will only run the application once and not twice.Sergej Koščejev
10/19/2024, 6:44 PMrun conditionally based on some Gradle property passed to the build.Arjan van Wieringen (avwie)
10/19/2024, 7:33 PMArjan van Wieringen (avwie)
10/19/2024, 7:33 PMArjan van Wieringen (avwie)
10/19/2024, 7:37 PMVampire
10/20/2024, 12:07 AMrunDev task is configured (only configured, not executed), then the run task always has that parameter. So if you for example apply some (granted, misbehaving, but some plugins do) plugin that does some bad things like tasks.all { ... }, then the runDev task is always configured and thus the run task does always have that parameter, to only describe one of the problematic situations.
The main question is your use-case. For example do you want to be able to run both variants in one Gradle execution? If yes, then having two tasks (but don't properly) makes sense. But if you always want to only run one of those variants, it makes much more sense to conditionally configure that one task and not add another task. For example something like ./gradlew run -P runType=dev. And if a given person would practically always use that mode or at least most of the time, he could also simply set that property in his <GRADLE_USER_HOME>/gradle.properties file.Vampire
10/20/2024, 12:09 AMArjan van Wieringen (avwie)
10/20/2024, 6:38 AM