mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-01-11 22:41:09 +01:00
23 lines
461 B
Groovy
23 lines
461 B
Groovy
|
|
// Definition of custom task class
|
|
class DateTask extends DefaultTask {
|
|
|
|
String prefixText = "Today is:"
|
|
|
|
@TaskAction
|
|
void printDate() {
|
|
def dateTime = new Date()
|
|
println "${prefixText} ${dateTime.dateString}"
|
|
}
|
|
}
|
|
|
|
task today(type: DateTask) {
|
|
description "Display date"
|
|
}
|
|
|
|
task verboseToday(type: DateTask) {
|
|
description "Display polite message and date"
|
|
prefixText "I would like to inform you that today is:"
|
|
}
|
|
|