• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

hamsterksu/android-appversion-gradle-plugin: Add extra information to output fil ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

hamsterksu/android-appversion-gradle-plugin

开源软件地址(OpenSource Url):

https://github.com/hamsterksu/android-appversion-gradle-plugin

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

android-appversion-gradle-plugin

Android Arsenal

  1. Easy way to add build number to your application version
  2. Easy way to change APK name and add extra data to it.

Supported version of gradle-android-plugin

  • 0.12.+ -> Maven Central - com.github.hamsterksu:android-appversion-gradle-plugin:1.0.+
  • > 0.14.+ -> Maven Central - com.github.hamsterksu:android-appversion-gradle-plugin:1.2.+
  • 1.0.+ -> Maven Central - com.github.hamsterksu:android-appversion-gradle-plugin:1.2.+

Сontents

  1. How to use
  2. Add plugin to dependencies
  3. Apply plugin
  4. Configure plugin
  5. Available options
  6. Typical usecases
  7. Use brackets in some cases
  8. What is versions.properties file?
  9. Configuration examples

Typical usecases

Do you want to use package name, app version name and version code in file name?

Just use the following fileNameFormat: $appPkg.$versionName($versionCode)

Result - com.yourdomain.app.1.0.0.1(1).apk

Use brackets in some cases

Why do you need to use brackets {} in some cases?

fileNameFormat - is a Groovy string. Be careful to use something like $appPkg.v_$versionName. Groovy will try to find the "v_" property in the String object. And you will get Error: > No such property: v_ for class: java.lang.String.

In this case you need to use {}: ${appPkg}.v_$versionName

How to use

Add plugin to dependencies

buildscript {
    repositories {
		mavenCentral()
	}

	dependencies{
		classpath 'com.github.hamsterksu:android-appversion-gradle-plugin:1.+'
	}
}

Apply plugin

apply plugin: 'versionPlugin'

Configure plugin

versionPlugin{
	buildTypesMatcher = 'release'

	supportBuildNumber = true
	buildNumberPrefix = 'b'
	
	fileNameFormat = '$appPkg-v_$versionName-c_$versionCode'
}

Available options:##

  • buildTypesMatcher - regexp value. the most useful case: if you want to apply changes for one build type use buildTypesMatcher = 'release' if for both buildTypesMatcher = 'release|debug'. Sure you can use any regexp value.
  • supportBuildNumber - use true if you want to add build number to appVersion. versions.properties file will be generated in root project. you can add it to version control ignore list if you use CI or you are alone devloper in the team.
  • buildNumberPrefix - string value, prefix before build number. example: 1.0.0.b1
  • fileNameFormat - groovy template string. you can specify your own format of APK file name. Available variables in the formatted string:
    • appName - name of main module
    • projectName - name of root project
    • flavorName - falvour name
    • buildType - build type
    • versionName - version name
    • versionCode - version code
    • appPkg - application id
    • date - build date, you can specify your own date format use dateFormat propery
    • time - build time, you can specify your own date format use timeFormat propery
    • customName - use this template to use string from customNameMapping
  • dateFormat - format string for SimpleDateFormat
  • timeFormat - format string for SimpleDateFormat
  • customNameMapping - mapping for $customName. it's groovy map for variantName -> text

Example:

customNameMapping = [
    'debug':'MySuperApp',
    'releae':'MySuperApp'
]
customNameMapping = [
    'flavourDebug':'MySuperApp',
    'flavourRelease':'MySuperApp'
]

What is versions.properties file?

If you turn on supportBuildNumber plugin will generate versions.properties file in root project. it store current build number for each flavour. You can add it to version control ignore list if you use CI or you are alone devloper in the team.

Config examples

versionPlugin{
    buildTypesMatcher = 'release|debug'

    supportBuildNumber = true
    buildNumberPrefix = 'b'

    fileNameFormat = '$customName-$versionName($versionCode)-$buildType'

    customNameMapping = [
    	'debug':'mysuperapp',
        'release':'mysuperapp'
    ]
}
versionPlugin{
    buildTypesMatcher = 'release'
    supportBuildNumber = true
    
    fileNameFormat = '$appPkg-$versionName($versionCode)'
}
versionPlugin{
    buildTypesMatcher = 'release'
    supportBuildNumber = false
    
    fileNameFormat = '$projectName-$flavorName-$versionName($versionCode)-$date-$time'
    dateFormat = 'dd-MM-yyyy'
    timeFormat = 'HH:mm'
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
RobertFischer/gradle-plugins: Plugins for Gradle发布时间:2022-06-14
下一篇:
zengjingfang/TinyPIC_Gradle_Plugin: TinyPIC_Gradle_Plugin发布时间:2022-06-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap