reckon 用法
github地址:[https://github.com/ajoberstar/reckon]
根项目 gradle配置
buildscript {
apply from: 'versions.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'org.ajoberstar:grgit:2.3.0'
classpath 'org.ajoberstar.reckon:reckon-gradle:0.13.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
configure(rootProject) {
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'org.ajoberstar.reckon'
reckon {
scopeFromProp()
stageFromProp('develop', 'release', 'hotfix', 'final')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
项目modul中gradle配置
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.plugin"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode 12
versionName "1.2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
keyAlias 'android_debug_key'
keyPassword 'android'
storeFile file("${rootDir}/config/signing/debug.keystore")
storePassword 'android'
}
release {
keyAlias 'android_release_key'
keyPassword 'releaseandroid'
storeFile file("${rootDir}/config/signing/release.keystore")
storePassword 'ctsiandroid'
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
flavorDimensions 'environments'
productFlavors{
//测试环境
qetest{
buildConfigField "int" ,"ENV_TYPE","1"
buildConfigField "String","VERSION_APP","\"123-1\""
buildConfigField "String","APP_KEY","\"test\""
dimension "environments"
}
//预发布环境
develop{
buildConfigField "int" ,"ENV_TYPE","2"
buildConfigField "String","VERSION_APP","\"123-2\""
buildConfigField "String","APP_KEY","\"develop\""
dimension "environments"
}
//生产环境
porduct{
buildConfigField "int" ,"ENV_TYPE","3"
buildConfigField "String","VERSION_APP","\"123-3\""
buildConfigField "String","APP_KEY","\"porduct\""
dimension "environments"
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//渠道打包
implementation 'com.meituan.android.walle:library:1.1.7'
}
打包命令:
gradlew build -Preckon.scope=minor -Preckon.stage=develop clean assembleRelease
scope = [major,minor,patch]
<major> 版本号第一位,正整数递增 {1.0.0}
<minor> 在添加功能的同时增加正整数,同时保持向后兼容 [ 1.2.0 ]
<patch> 进行修正以保持向后兼容性时,递增正整数 [ 1.2.1 ]
stage = [fianl,develop,release,hotfix]字母标识符,指示最终发行途中的成熟度。它们对人类应该具有逻辑意义,但是字母顺序必须是成熟度的指标,以确保它们正确排序。(例如,里程碑,rc,快照没有意义,因为快照将在rc之后排序)
<develop> 例:1.0.0-develop.1
<release> 例:1.0.0-release.1
<hotfix> 例:1.0.0-hotfix.1
<final> 例:1.0.1