博客
关于我
android studio3.0build.gradle包含的svn信息apk名称写法等
阅读量:402 次
发布时间:2019-03-05

本文共 2385 字,大约阅读时间需要 7 分钟。

import java.text.SimpleDateFormatimport java.util.regex.Matcherimport java.util.regex.Patternapply plugin: 'com.android.application'android {    compileSdkVersion 26    defaultConfig {        applicationId "com.excellence.netlink"        minSdkVersion 17        targetSdkVersion 26        versionCode = getSvnVersion()        versionName = "V2.0." + versionCode + ' [' + getDate()+ "]"        println 'versionCode: '+versionCode + '\n' + 'versionName: '+versionName        creatVersionInfo()    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    applicationVariants.all{ variant->        variant.getPackageApplication().outputDirectory = new File(outputDir())        variant.outputs.all { output->            if (variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {                outputFileName= "m3u8Player"+versionName+".apk"            }        }    }}def outputDir(){    return project.buildDir.absolutePath+"/outputs/apk"}def getSvnVersion() {    def proc = ("svnversion -c " + getBuildDir().parent).execute();    proc.waitFor();    def version = proc.in.text;    Pattern p = Pattern.compile("(\\d+\\:)?(\\d+)\\D?");    Matcher m = p.matcher(version);    if (m.find()) {        version = m.group(m.groupCount());    }    try    {        return Integer.parseInt(version);    }    catch (e)    {        println e.getMessage()    }    return 0;}def getDate() {    SimpleDateFormat sdf = new SimpleDateFormat('MMM d yyyy', Locale.US);    return sdf.format(new Date());}def creatVersionInfo() {    try    {        FileOutputStream outStream = new FileOutputStream(getBuildDir().parent + '/assets/verson_config.properties');        Properties properties = new Properties();        properties.put("svn_ver", '' + getSvnVersion());        properties.put("build_time", getDate());        properties.store(outStream, null);        outStream.flush();        outStream.close();    }    catch (e)    {        println e.getMessage()    }}dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    implementation 'com.jakewharton:butterknife:8.7.0'    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'    implementation 'com.vise.xiaoyaoyou:viselog:1.1.2'    implementation 'com.orhanobut:hawk:2.0.1'}

转载地址:http://vbbzz.baihongyu.com/

你可能感兴趣的文章
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
MySQL InnoDB 三大文件日志,看完秒懂
查看>>
Mysql InnoDB 数据更新导致锁表
查看>>
Mysql Innodb 锁机制
查看>>
MySQL InnoDB中意向锁的作用及原理探
查看>>
MySQL InnoDB事务隔离级别与锁机制深入解析
查看>>
Mysql InnoDB存储引擎 —— 数据页
查看>>
Mysql InnoDB存储引擎中的checkpoint技术
查看>>
Mysql InnoDB存储引擎中缓冲池Buffer Pool、Redo Log、Bin Log、Undo Log、Channge Buffer
查看>>
MySQL InnoDB引擎的锁机制详解
查看>>
Mysql INNODB引擎行锁的3种算法 Record Lock Next-Key Lock Grap Lock
查看>>
mysql InnoDB数据存储引擎 的B+树索引原理
查看>>
mysql innodb通过使用mvcc来实现可重复读
查看>>
mysql insert update 同时执行_MySQL进阶三板斧(三)看清“触发器 (Trigger)”的真实面目...
查看>>
mysql interval显示条件值_MySQL INTERVAL关键字可以使用哪些不同的单位值?
查看>>