首页 > 其他 > 详细

Gradle basic

时间:2015-10-24 06:39:04      阅读:290      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!