I've written simple custom Gradle task that extends DefaultTask and does some action and I would like to pass it some parameter(s) using command line. At the bottom is code for adding task to list of available tasks and "implementation" of the task.
Now, when I execute: ./gradlew customTask -PcustomParam="value" how can I retrieve customParam value in doAction method?
project.tasks.create("customTask", CustomTask::class.java
open class CustomTask : DefaultTask() {
@TaskAction
fun doAction() {
// retrieve passed parameter
}
}
if (project.hasProperty('customParam')) {
println project.property('customParam')
}
@see project.property(String name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With