49 lines
1.4 KiB
Groovy
49 lines
1.4 KiB
Groovy
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_ENABLE = true
|
|
BUGLY_ID = "5226e86a6e"
|
|
if (serverType == SERVER_TYPE_PREVIEW) {
|
|
HOST_URL = "https://www.pre.baidu.com/"
|
|
} else {
|
|
HOST_URL = "https://www.test.baidu.com/"
|
|
}
|
|
break
|
|
case SERVER_TYPE_PRODUCT:
|
|
LOG_ENABLE = false
|
|
BUGLY_ID = "5226e86a6e"
|
|
HOST_URL = "https://www.baidu.com/"
|
|
break
|
|
}
|
|
} |