mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-04-18 06:30:15 +02:00
Add example with custom task in one and separate files
This commit is contained in:
10
22-custom-task-in-buildSrc/build.gradle
Normal file
10
22-custom-task-in-buildSrc/build.gradle
Normal file
@@ -0,0 +1,10 @@
|
||||
apply plugin: 'groovy'
|
||||
|
||||
import com.ysoft.greeting.GreetingTask
|
||||
|
||||
task hello(type: GreetingTask)
|
||||
|
||||
// Customize the greeting
|
||||
task greeting(type: GreetingTask) {
|
||||
greeting = 'greetings from Brno'
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ysoft.greeting
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
class GreetingTask extends DefaultTask {
|
||||
String greeting = 'hello from Y Soft'
|
||||
|
||||
@TaskAction
|
||||
def greet() {
|
||||
println greeting
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user