码迷,mamicode.com
首页 > 其他好文 > 详细

Gradle basic

时间:2015-10-24 06:40:51      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

1. execute default file (build.gradle)

gradlew

2. execute another file

gradlew -b [filename]

3.  basic task

task ta {
    println "from task ta"
}

another way to define task

task tc
tc.doLast{println "from task tc"}

4. task with left shift

will not be execute like this

gradlew

only execute when call task name

gradlew ta
task ta <<{
    println "from task ta"
}

equal to 

task ta {
    doLast {
        println "from task ta"
    }
}

 5. dependsOn

do before the task

task putOnSocks {
    doLast {
        println "Putting on Socks."
    }
}

task putOnShoes {
    dependsOn "putOnSocks"
    doLast {
        println "Putting on Shoes."
    }
}

6. finalizedBy

do after the task

task eatBreakfast {
    finalizedBy "brushYourTeeth"
    doLast{
        println "Om nom nom breakfast!"
    }
}

task brushYourTeeth {
    doLast {
        println "Brushie Brushie Brushie."
    }
}

7. copy task

task copyJpegs(type: Copy) {
    from ‘images‘
    include ‘*.jpg‘
    into ‘build‘
}

 8. define a task type

// type definition
class HelloNameTask extends DefaultTask {
    String firstName

    @TaskAction
    void doAction() {
        println "Hello, $firstName"
    }
}


// create a task with type
task helloName(type: HelloNameTask) {
    firstName = ‘Jeremy‘
}

 

Gradle basic

标签:

原文地址:http://www.cnblogs.com/phoenix13suns/p/4906084.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!