This message was deleted.
# community-support
s
This message was deleted.
j
prop.get()
or
prop.orNull
d
you mean
properties["option-1"]
in my case ?
j
no, your property variable
Copy code
val myVariable: Property<String>
Copy code
myVariable.orNull
d
./gradlew :myTask --download-path="/here/file.ext"
Copy code
tassk.register("myTask",Myclass::class){
println(downloadPath.get())
}
This throws error > Cannot query the value of task ':myTask' property 'downloadPath' because it has no value available.
j
orNull
and call that inside
doLast { … }
d
doLast{ ... }
means its gonna execute after the taskAction right. I need to check this before the taskAction is executed. use case is that if the option
--download-path
is not provided I need to check a few things and then set its value.
Is there a different way to approach this ?
j
doFirst
d
Then its null even though i provide
--download-path
j
I don’t know then, tbh I don’t use these, I just do everything inside the task action, and the register block is just for wiring the task inputs
d
I understand and Thank you for your time and help. I was doing the same. But task needs to set the
@Outputfile
which is kinda dependent on the
--download-path
if provided and I couldn't achieve that from within the taskAction
j
I don’t follow you, that option is provided via cli, you can get it inside the task action and it is not set, throw an error with a specific message
or you mean you want to provide a default value if the user doesn’t provide one via cli
d
yes if the option is not provided then I download the file to a specific location and name. This becomes the outputfile of the task.
j
inside
register
do
myProperty.convention(“…”)
or
myProperty.set(“…”)
if the user provides one via cli, it will be used, if not it will get what you put there
d
Thankyou! will try that