Android reckon 控制项目打包版本

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
 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值