gradle 内容学习参考

1、用Gradle打包出jar文件

http://unclechen.github.io/2015/10/25/Gradle%E5%AE%9E%E8%B7%B5%E4%B9%8B%E6%89%93%E5%8C%85jar+Log%E5%BC%80%E5%85%B3%E8%87%AA%E5%8A%A8%E5%85%B3%E9%97%AD/

https://www.jianshu.com/p/ed4ef3b96a29

2、在Android Studio中编译出jar包

gradle中支持jar操作,可以将classes.dex直接变成jar包:不过当前的gradle一定是编译apk的型:com.android.application

task makeSDKJar(dependsOn: "assembleRelease", type: Jar) {
    baseName 'finaljar'
    from('build/intermediates/transforms/jack/release/classes.dex')
    destinationDir = file("output")
}

3、执行shell脚本,判断文件是否存在

def targetPath = file("YOUR/TARGET/FILES")
task shellexe(type: Exec) {

    if (!targetPath.exists()) {
        project.exec {
            println "the path is not exsit."
            commandLine "./shelldemo.sh"
        }
    }

    else println "preprocess the path is  exsit already."

}

4、task clean只能在根目录的build.gradle下面定义,不能够在其它目录下面的gradle定义。

 

posted @ 2018-05-08 11:54  Create-Heart  阅读(161)  评论(0编辑  收藏  举报