Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit daf69bb

Browse files
committedApr 12, 2020
AucFrame 之些许优化
1 parent ae83a12 commit daf69bb

File tree

8 files changed

+38
-50
lines changed

8 files changed

+38
-50
lines changed
 

‎buildAPP.gradle ‎buildApp.gradle

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apply {
22
plugin "com.android.application"
33
plugin "kotlin-android"
44
plugin "kotlin-android-extensions"
5-
plugin "com.blankj.api"
6-
plugin "com.blankj.bus"
5+
plugin Config.depConfig.plugin_api.pluginId
6+
plugin Config.depConfig.plugin_bus.pluginId
77
}
88

99
android {
@@ -47,8 +47,6 @@ android {
4747
dependencies {
4848
// LeakCanary
4949
debugImplementation Config.depConfig.leakcanary_android.dep
50-
debugImplementation Config.depConfig.leakcanary_support_fragment.dep
51-
releaseImplementation Config.depConfig.leakcanary_android_no_op.dep
5250

5351
// 根据 Config.pkgConfig 来依赖所有 pkg
5452
for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) {
@@ -61,6 +59,6 @@ dependencies {
6159
}
6260

6361
def getSuffix() {
64-
if (project.path == ":feature:launcher:app") return ""
65-
return project.path.replace(":", "_").substring(":feature".length(), project.path.length() - ":app".length())
62+
if (project.name == "feature_launcher_app") return ""
63+
return "." + project.name.substring("feature_".length(), project.name.length() - "_app".length())
6664
}

‎buildLib.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ android {
2828
}
2929

3030
dependencies {
31-
if (project.name == 'pkg' || project.name == 'mock') {
31+
if (project.name.endsWith("_pkg") || project.name.endsWith("_mock")) {
3232
// if module's name equals 'pkg', api all of export
3333
for (def entrySet : ConfigUtils.getApplyExports().entrySet()) {
3434
api entrySet.value.dep
3535
}
36-
} else if (project.name == 'export') {
36+
} else if (project.name.endsWith("_export")) {
3737
api Config.depConfig.lib_common.dep
3838
}
3939
}

‎buildSrc/src/main/groovy/Config.groovy

+22-24
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,42 @@ class Config {
99
static versionCode = 1_000_000 // TODO: MODIFY
1010
static versionName = '1.0.0'// E.g. 1.9.72 => 1,009,072 // TODO: MODIFY
1111

12-
static kotlin_version = '1.3.50'
13-
static support_version = '27.1.1'
14-
static leakcanary_version = '1.6.3'
12+
static gradlePluginVersion = '3.5.0'
13+
static kotlinVersion = '1.3.50'
14+
static supportVersion = '27.1.1'
1515

1616
static depConfig = [
1717
/*Never delete this line*/
1818
/*Generated by "config.json"*/
19-
feature_mock : new DepConfig(false, true, ":feature:mock"),
20-
feature_launcher_app : new DepConfig(true, true, ":feature:launcher:app"),
21-
feature_feature0_app : new DepConfig(false, true, ":feature:feature0:app"),
22-
feature_feature0_pkg : new DepConfig(true, true, ":feature:feature0:pkg", "com.blankj:feature-feature0-pkg:1.0"),
23-
feature_feature0_export : new DepConfig(true, true, ":feature:feature0:export"),
24-
feature_feature1_app : new DepConfig(false, true, ":feature:feature1:app"),
25-
feature_feature1_pkg : new DepConfig(true, true, ":feature:feature1:pkg"),
26-
feature_feature1_export : new DepConfig(true, true, ":feature:feature1:export"),
27-
lib_base : new DepConfig(true, true, ":lib:base"),
28-
lib_common : new DepConfig(true, true, ":lib:common"),
19+
feature_mock : new DepConfig(false, true , ":feature:mock"),
20+
feature_launcher_app : new DepConfig(true , true , ":feature:launcher:app"),
21+
feature_feature0_app : new DepConfig(false, true , ":feature:feature0:app"),
22+
feature_feature0_pkg : new DepConfig(true , true , ":feature:feature0:pkg", "com.blankj:feature-feature0-pkg:1.0"),
23+
feature_feature0_export : new DepConfig(true , true , ":feature:feature0:export"),
24+
feature_feature1_app : new DepConfig(false, true , ":feature:feature1:app"),
25+
feature_feature1_pkg : new DepConfig(true , true , ":feature:feature1:pkg"),
26+
feature_feature1_export : new DepConfig(true , true , ":feature:feature1:export"),
27+
lib_base : new DepConfig(true , true , ":lib:base"),
28+
lib_common : new DepConfig(true , true , ":lib:common"),
2929
/*Never delete this line*/
3030
// feature_template_app : new DepConfig(":feature:template:app"),
3131
// feature_template_pkg : new DepConfig(":feature:template:pkg"),
3232
// feature_template_export : new DepConfig(":feature:template:export"),
33-
plugin_gradle : new DepConfig(pluginPath: "com.android.tools.build:gradle:3.3.0"),
34-
plugin_kotlin : new DepConfig(pluginPath: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"),
35-
plugin_api : new DepConfig(pluginPath: "com.blankj:api-gradle-plugin:1.1", pluginId: "com.blankj.api"),
36-
plugin_bus : new DepConfig(pluginPath: "com.blankj:bus-gradle-plugin:2.3", pluginId: "com.blankj.bus"),
33+
plugin_gradle : new DepConfig(pluginPath: "com.android.tools.build:gradle:$gradlePluginVersion"),
34+
plugin_kotlin : new DepConfig(pluginPath: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"),
35+
plugin_api : new DepConfig(pluginPath: "com.blankj:api-gradle-plugin:1.2", pluginId: "com.blankj.api"),
36+
plugin_bus : new DepConfig(pluginPath: "com.blankj:bus-gradle-plugin:2.4", pluginId: "com.blankj.bus"),
3737

38-
support_appcompat_v7 : new DepConfig("com.android.support:appcompat-v7:$support_version"),
39-
support_design : new DepConfig("com.android.support:design:$support_version"),
38+
support_appcompat_v7 : new DepConfig("com.android.support:appcompat-v7:$supportVersion"),
39+
support_design : new DepConfig("com.android.support:design:$supportVersion"),
4040
support_multidex : new DepConfig("com.android.support:multidex:1.0.2"),
4141
support_constraint : new DepConfig("com.android.support.constraint:constraint-layout:1.1.3"),
4242

43-
kotlin : new DepConfig("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"),
44-
utilcode : new DepConfig("com.blankj:utilcode:1.25.10-alpha5"),
43+
kotlin : new DepConfig("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"),
44+
utilcode : new DepConfig("com.blankj:utilcode:1.28.0"),
4545
free_proguard : new DepConfig("com.blankj:free-proguard:1.0.1"),
4646
swipe_panel : new DepConfig("com.blankj:swipe-panel:1.1"),
4747

48-
leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:$leakcanary_version"),
49-
leakcanary_android_no_op : new DepConfig("com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"),
50-
leakcanary_support_fragment: new DepConfig("com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version"),
48+
leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:2.1"),
5149
]
5250
}

‎buildSrc/src/main/groovy/ConfigUtils.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class ConfigUtils {
1818
def configs = [:]
1919
for (Map.Entry<String, DepConfig> entry : Config.depConfig.entrySet()) {
2020
def (name, config) = [entry.key, entry.value]
21-
if (name.startsWith("plugin_")) {
21+
if (config.pluginPath) {
2222
config.dep = config.pluginPath
2323
} else {
2424
if (config.useLocal) {
25-
config.dep = gradle.rootProject.findProject(config.localPath)
25+
config.dep = gradle.rootProject.findProject(config.projectPath)
2626
} else {
2727
config.dep = config.remotePath
2828
}
@@ -41,7 +41,7 @@ class ConfigUtils {
4141
if (project.path.contains(":plugin:")) {
4242
return
4343
}
44-
if (project.name == "app") {
44+
if (project.name.endsWith("_app")) {
4545
GLog.l(project.toString() + " applies buildApp.gradle")
4646
project.apply {
4747
from "${project.rootDir.path}/buildApp.gradle"

‎buildSrc/src/main/groovy/DepConfig.groovy

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class DepConfig {
7070
return splits.length == 3 ? splits[2] : null
7171
}
7272

73+
String getProjectPath() {
74+
return localPath.substring(0, localPath.lastIndexOf(":")) + ":" + localPath.substring(1).replace(":", "_")
75+
}
76+
7377
@Override
7478
String toString() {
7579
return "{ isApply = ${getFlag(isApply)}" +

‎lib/base/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ dependencies {
99
api Config.depConfig.support_multidex.dep
1010
api Config.depConfig.support_constraint.dep
1111
api Config.depConfig.kotlin.dep
12-
compileOnly Config.depConfig.leakcanary_android_no_op.dep
1312
}

‎lib/base/src/main/java/com/blankj/base/BaseApplication.java

-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.blankj.utilcode.util.CrashUtils;
99
import com.blankj.utilcode.util.LogUtils;
1010
import com.blankj.utilcode.util.ProcessUtils;
11-
import com.squareup.leakcanary.LeakCanary;
1211

1312
import java.util.ArrayList;
1413

@@ -34,22 +33,10 @@ protected void attachBaseContext(Context base) {
3433
public void onCreate() {
3534
super.onCreate();
3635
sInstance = this;
37-
initLeakCanary();
3836
initLog();
3937
initCrash();
4038
}
4139

42-
private void initLeakCanary() {// 内存泄露检查工具
43-
if (isDebug()) {
44-
if (LeakCanary.isInAnalyzerProcess(this)) {
45-
// This process is dedicated to LeakCanary for heap analysis.
46-
// You should not init your app in this process.
47-
return;
48-
}
49-
LeakCanary.install(this);
50-
}
51-
}
52-
5340
// init it in ur application
5441
public void initLog() {
5542
LogUtils.Config config = LogUtils.getConfig()

‎settings.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ for (def pro in config.proConfig) {
2828

2929
if (pro.useLocal && pro.isApply) {
3030
include pro.localPath
31+
project(pro.localPath).name = pro.localPath.substring(1).replace(":", "_")
3132
}
3233
}
3334

@@ -42,7 +43,8 @@ for (def pro in config.proConfig) {
4243
if (localPath != null) localPath = "\"$localPath\""
4344
if (remotePath != null) remotePath = "\"$remotePath\""
4445
boolean isApply = pro.isApply
45-
proDeps.add(String.format("%-12s%-27s: new DepConfig($isApply, $useLocal, $localPath%s),", "", name, remotePath == null ? "" : ", $remotePath"))
46+
proDeps.add(String.format("%-12s%-27s: new DepConfig(%-5s, %-5s, $localPath%s),",
47+
"", name, isApply, useLocal, remotePath == null ? "" : ", $remotePath"))
4648
}
4749

4850
def configFile = file('./buildSrc/src/main/groovy/Config.groovy')

0 commit comments

Comments
 (0)