-
Notifications
You must be signed in to change notification settings - Fork 754
/
debug.gradle
56 lines (51 loc) · 1.55 KB
/
debug.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
println('gradle debug , init start')
if (!isNeedUsedDebug()) {
println('gradle debug , not need debug')
return
}
println('gradle debug isNeedUsedebug = ture')
android {
defaultConfig {
buildTypes {
debug {
println 'gradle debug debug test =====>'
}
release {
println 'gradle debug release test =====>'
}
}
}
}
dependencies {
// 只是在debug下依赖,各种测试工具lib可以放到这里
implementation project(path: ':ThreadDebugLib')
}
//过滤,只在debug下使用
def isNeedUsedDebug() {
Map<String, String> map = System.getenv()
if (map == null) {
return false
}
//拿到编译后的 BUILD_TYPE 和 CONFIG。具体看 BuildConfig 生成类的代码
boolean hasBuildType = map.containsKey("BUILD_TYPE")
boolean hasConfig = map.containsKey("CONFIG")
println 'gradle debug isNeedUsedebug hasBuildType =====>' + hasBuildType + ',hasConfig = ' + hasConfig
String buildType = "debug"
String config = "debug"
if (hasBuildType) {
buildType = map.get("BUILD_TYPE")
}
if (hasConfig) {
config = map.get("CONFIG")
}
println 'gradle debug isNeeddebug buildType =====>' + buildType + ',config = ' + config
if (buildType.toLowerCase() == "debug" && config.toLowerCase() == "debug" && isUseDebug()) {
println('gradle debug debug use debug')
return true
}
println('gradle debug not use debug')
return false
}
static def isUseDebug() {
return true
}