csonezp

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在project的build.gradle加上:

dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.8.11'
    }

 module的build.gradle加上:

def getSvnRevision() {
    ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
    SVNClientManager clientManager = SVNClientManager.newInstance(options);
    SVNStatusClient statusClient = clientManager.getStatusClient();
    SVNStatus status = statusClient.doStatus(projectDir, false);
    SVNRevision revision = status.getCommittedRevision();
    return revision.getNumber();

 

 buildTypes {
        release {

            minifyEnabled true

            zipAlignEnabled true
            // 移除无用的resource文件
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFile
                   //这里修改文件名
                    def fileName = ${getSvnRevision()}+outputFile.name
                    output.outputFile = new File(outputFile.parent, fileName)
                   
                }
            }
        }

 

posted on 2015-10-23 13:47  csonezp  阅读(1002)  评论(0编辑  收藏  举报