Slackbot
10/02/2023, 1:01 PMJavi
10/02/2023, 1:03 PM@Optional
Javi
10/02/2023, 1:03 PMabstract class MyTask : DefaultTask() {
@Option(option = "console", description = "")
@Input
@Optional
val taskOption: String = "plain"
@TaskAction
fun action() {
// My action
}
}
samuel
10/02/2023, 1:05 PMNiels Doucet
10/02/2023, 1:05 PMNiels Doucet
10/02/2023, 1:05 PMJavi
10/02/2023, 1:09 PM@Input
@Option(option = "added", description = "Add an item to the `added` section")
@Optional
public val added: Property<String?> = objects.property()
Maybe you can check if it is null
and use a default value based on that.samuel
10/02/2023, 1:11 PMJavi
10/02/2023, 1:12 PMJavi
10/02/2023, 1:13 PM./gradlew myTask
would mean that taskOption
is null, so you can check that and use a different value inside the @TaskAction
functionsamuel
10/02/2023, 1:15 PM--console=plain
is intended to change the console output which was my intention, passing the option to the task would work but it would not affect the console outputJavi
10/02/2023, 1:15 PMsamuel
10/02/2023, 1:16 PMNiels Doucet
10/02/2023, 1:30 PMsamuel
10/02/2023, 1:33 PM--console=plain
option because my task would require user input which becomes quite unclear with the โregularโ mode. The reason i want it built in is for better user experience, it is much more convenient to just need to type the task nameNiels Doucet
10/02/2023, 1:46 PMNiels Doucet
10/02/2023, 1:47 PMsamuel
10/02/2023, 1:51 PMNiels Doucet
10/02/2023, 1:59 PMSystem.console
that made me abandon the idea, but it's been a while. So I might just be completely misremembering ๐คทsamuel
10/02/2023, 2:29 PM