android 中的每日构造 ——android stuido 中的build.gradle示例

来源:互联网 发布:撒贝宁智商知乎 编辑:程序博客网 时间:2024/06/09 21:12
import org.tmatesoft.svn.core.wc.*apply plugin: 'com.android.application'//发布时间def releaseTime() {    return new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT"))}//获取svn的版本号def getSvnRevision() {    ISVNOptions options = SVNWCUtil.createDefaultOptions(true);    SVNClientManager clientManager = SVNClientManager.newInstance(options);    SVNStatusClient statusClient = clientManager.getStatusClient();    SVNStatus status = statusClient.doStatus(rootDir, false);    SVNRevision revision = status.getCommittedRevision();    return revision.getNumber();}android {    compileSdkVersion 23    buildToolsVersion "23.0.0"    useLibrary 'org.apache.http.legacy'    defaultConfig {        multiDexEnabled true        applicationId "com.example.agentproject"        minSdkVersion 15        targetSdkVersion 20        versionCode 2        versionName "2.0.26"    }    //签名    signingConfigs {        debug {            keyAlias 'sdroid'            keyPassword 'test123456'            storeFile file('signer/client.jks')            storePassword 'test123456'        }        release {            keyAlias 'sdroid'            keyPassword 'test123456'            storeFile file('signer/client.jks')            storePassword 'test123456'        }    }    buildTypes {        debug {            signingConfig signingConfigs.debug        }
        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            signingConfig signingConfigs.release // 配置release包的签名及生成的apk的文件名            applicationVariants.all { variant ->                variant.outputs.each { output ->                    def outputFile = output.outputFile                    //这里修改文件名                    def fileName = "at.apk"                    output.outputFile = new File(outputFile.parent, fileName)                }            }        }    }    lintOptions{        abortOnError false    }}//编译依赖文件dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    testCompile 'junit:junit:4.12'    compile 'org.tmatesoft.svnkit:svnkit-dav:1.8.14'    compile files('libs/dom4j-1.6.1.jar')}//最后将生成的apk复制到指定目录下并修改名称build {    doLast {        def versionName = android.defaultConfig.versionName        def sourceName = "at.apk";        def fileName = "at-android-${versionName}-build${getSvnRevision()}-${releaseTime()}.apk"        def fromFile = "./build/outputs/apk/" + sourceName        def intoFile = "../target/${releaseTime()}/";        // copy --> rename        copy {            from fromFile            into intoFile            rename(sourceName, fileName)        }    }}
0 0