How to call a task in another task in Gradle

现希望能在build.gradle中调用定义在customizeTask.gradle的一个task

build.task

 

apply plugin:'groovy'


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

 

 

posted @ 2012-09-12 13:35  卜海清  阅读(1762)  评论(0编辑  收藏  举报