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')
}