现希望能在build.gradle中调用定义在customizeTask.gradle的一个task
build.task
apply plugin:'groovy'
task hello {
apply from:'customizeTask.gradle'
greeting.execute()
}
task hello {
apply from:'customizeTask.gradle'
greeting.execute()
}
customizeTask.gradle
// Customize the greeting
task greeting(type: GreetingTask) {
greeting = 'greetings from GreetingTask'
}
class GreetingTask extends DefaultTask {
def String greeting = 'hello from GreetingTask'
@TaskAction
def greet() {
println greeting
}
}
task greeting(type: GreetingTask) {
greeting = 'greetings from GreetingTask'
}
class GreetingTask extends DefaultTask {
def String greeting = 'hello from GreetingTask'
@TaskAction
def greet() {
println greeting
}
}