ext { // 测试服 def SERVER_TYPE_TEST = "test" // 预发布服 def SERVER_TYPE_PREVIEW = "pre" // 正式服 def SERVER_TYPE_PRODUCT = "product" def taskName = project.gradle.startParameter.taskNames[0] if (taskName == null) { taskName = "" } // 打印当前执行的任务名称 println "GradleLog TaskNameOutput " + taskName def serverType = SERVER_TYPE_PRODUCT if (taskName.endsWith("Debug")) { serverType = SERVER_TYPE_TEST } else if (taskName.endsWith("Preview")) { serverType = SERVER_TYPE_PREVIEW } // 从 Gradle 命令中读取参数配置,例如:./gradlew assembleRelease -P ServerType="test" if (project.hasProperty("ServerType")) { serverType = project.properties["ServerType"] } // 打印当前服务器配置 println "GradleLog ServerTypeOutput " + serverType switch(serverType) { case SERVER_TYPE_TEST: case SERVER_TYPE_PREVIEW: LOG_DEBUG = true BUGLY_ID = "c27876500b" if (serverType == SERVER_TYPE_PREVIEW) { SERVER_HOST = "https://wx.hzliuzhi.com:4433" } else { SERVER_HOST = "https://wx.hzliuzhi.com:4433" } break case SERVER_TYPE_PRODUCT: LOG_DEBUG = false BUGLY_ID = "c27876500b" SERVER_HOST = "http://8.139.252.178:8001" break } build = [ //签名信息 signingConfig : { storeFile file('./decoct.jks') storePassword 'decoct2024' keyAlias 'decoct.keystore' keyPassword 'decoct2024' v1SigningEnabled true v2SigningEnabled true } ] android = [ compileSdkVersion: 31, buildToolsVersion: "30.0.3", minSdkVersion : 21, targetSdkVersion : 31, versionCode : 1, versionName : "1.0.0", ] version = [ androidXSdkVersion : "1.3.0", constraintlayoutVersion: "2.0.3", retrofitSdkVersion : "2.4.0", okhttpSdkVersion : "3.12.0", rxandroid2SdkVersion : "2.1.1", rxjava2SdkVersion : "2.2.19", rxpermissionsSdkVersion: "0.10.2", eventbusSdkVersion : "3.1.1", butterknifeSdkVersion : "10.1.0", glideSdkVersion : "4.12.0", multidexSdkVersion : "2.0.1", rxlifecycleSdkVersion : "3.1.0", testEspressoSdkVersion : "3.3.0", testExtSdkVersion : "1.1.2" ] dependencies = [ //androidx "appcompat" : "androidx.appcompat:appcompat:${version["androidXSdkVersion"]}", "design" : "com.google.android.material:material:${version["androidXSdkVersion"]}", "legacy-support-v4" : "androidx.legacy:legacy-support-v4:1.0.0", "cardview" : "androidx.cardview:cardview:1.0.0", "annotations" : "androidx.annotation:annotation:${version["androidXSdkVersion"]}", "recyclerview" : "androidx.recyclerview:recyclerview:${version["androidXSdkVersion"]}", "constraintlayout" : "androidx.constraintlayout:constraintlayout:${version["constraintlayoutVersion"]}", //network "retrofit" : "com.squareup.retrofit2:retrofit:${version["retrofitSdkVersion"]}", "retrofit-converter-gson" : "com.squareup.retrofit2:converter-gson:${version["retrofitSdkVersion"]}", "retrofit-adapter-rxjava2" : "com.squareup.retrofit2:adapter-rxjava2:${version["retrofitSdkVersion"]}", "okhttp3" : "com.squareup.okhttp3:okhttp:${version["okhttpSdkVersion"]}", "okhttp3-logging-interceptor": "com.squareup.okhttp3:logging-interceptor:${version["okhttpSdkVersion"]}", "glide" : "com.github.bumptech.glide:glide:${version["glideSdkVersion"]}", "glide-compiler" : "com.github.bumptech.glide:compiler:${version["glideSdkVersion"]}", "glide-loader-okhttp3" : "com.github.bumptech.glide:okhttp3-integration:${version["glideSdkVersion"]}", //view "butterknife" : "com.jakewharton:butterknife:${version["butterknifeSdkVersion"]}", "butterknife-compiler" : "com.jakewharton:butterknife-compiler:${version["butterknifeSdkVersion"]}", "vlayout" : "com.alibaba.android:vlayout:1.2.6@aar", "autosize" : "me.jessyan:autosize:1.2.1", "multidex" : "androidx.multidex:multidex:${version["multidexSdkVersion"]}", //rx2 "rxandroid2" : "io.reactivex.rxjava2:rxandroid:${version["rxandroidSdkVersion"]}", "rxjava2" : "io.reactivex.rxjava2:rxjava:${version["rxjavaSdkVersion"]}", "rxpermissions" : "com.github.tbruyelle:rxpermissions:${version["rxpermissionsSdkVersion"]}", "rxlifecycle" : "com.trello.rxlifecycle3:rxlifecycle:${version["rxlifecycleSdkVersion"]}", "rxlifecycle-android" : "com.trello.rxlifecycle3:rxlifecycle-android:${version["rxlifecycleSdkVersion"]}", "rxlifecycle-components" : "com.trello.rxlifecycle3:rxlifecycle-components:${version["rxlifecycleSdkVersion"]}", "eventbus" : "org.greenrobot:eventbus:${version["eventbusSdkVersion"]}", "eventbus-compiler" : "org.greenrobot:eventbus-annotation-processor:${version["eventbusSdkVersion"]}", "arouter" : "com.alibaba:arouter-api:1.3.1", "arouter-compiler" : "com.alibaba:arouter-compiler:1.1.4", "progressmanager" : "me.jessyan:progressmanager:1.5.0", "retrofit-url-manager" : "me.jessyan:retrofit-url-manager:1.4.0", "junit" : "junit:junit:4.12", "androidTestExt" : "androidx.test.ext:junit:${version["testExtSdkVersion"]}", "androidTestEspresso" : "androidx.test.espresso:espresso-core:${version["testEspressoSdkVersion"]}" ] }