Skip to content

Commit

Permalink
AucFrame 之些许优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Apr 12, 2020
1 parent ae83a12 commit daf69bb
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 50 deletions.
10 changes: 4 additions & 6 deletions buildAPP.gradle → buildApp.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apply {
plugin "com.android.application"
plugin "kotlin-android"
plugin "kotlin-android-extensions"
plugin "com.blankj.api"
plugin "com.blankj.bus"
plugin Config.depConfig.plugin_api.pluginId
plugin Config.depConfig.plugin_bus.pluginId
}

android {
Expand Down Expand Up @@ -47,8 +47,6 @@ android {
dependencies {
// LeakCanary
debugImplementation Config.depConfig.leakcanary_android.dep
debugImplementation Config.depConfig.leakcanary_support_fragment.dep
releaseImplementation Config.depConfig.leakcanary_android_no_op.dep

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

def getSuffix() {
if (project.path == ":feature:launcher:app") return ""
return project.path.replace(":", "_").substring(":feature".length(), project.path.length() - ":app".length())
if (project.name == "feature_launcher_app") return ""
return "." + project.name.substring("feature_".length(), project.name.length() - "_app".length())
}
4 changes: 2 additions & 2 deletions buildLib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ android {
}

dependencies {
if (project.name == 'pkg' || project.name == 'mock') {
if (project.name.endsWith("_pkg") || project.name.endsWith("_mock")) {
// if module's name equals 'pkg', api all of export
for (def entrySet : ConfigUtils.getApplyExports().entrySet()) {
api entrySet.value.dep
}
} else if (project.name == 'export') {
} else if (project.name.endsWith("_export")) {
api Config.depConfig.lib_common.dep
}
}
46 changes: 22 additions & 24 deletions buildSrc/src/main/groovy/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,42 @@ class Config {
static versionCode = 1_000_000 // TODO: MODIFY
static versionName = '1.0.0'// E.g. 1.9.72 => 1,009,072 // TODO: MODIFY

static kotlin_version = '1.3.50'
static support_version = '27.1.1'
static leakcanary_version = '1.6.3'
static gradlePluginVersion = '3.5.0'
static kotlinVersion = '1.3.50'
static supportVersion = '27.1.1'

static depConfig = [
/*Never delete this line*/
/*Generated by "config.json"*/
feature_mock : new DepConfig(false, true, ":feature:mock"),
feature_launcher_app : new DepConfig(true, true, ":feature:launcher:app"),
feature_feature0_app : new DepConfig(false, true, ":feature:feature0:app"),
feature_feature0_pkg : new DepConfig(true, true, ":feature:feature0:pkg", "com.blankj:feature-feature0-pkg:1.0"),
feature_feature0_export : new DepConfig(true, true, ":feature:feature0:export"),
feature_feature1_app : new DepConfig(false, true, ":feature:feature1:app"),
feature_feature1_pkg : new DepConfig(true, true, ":feature:feature1:pkg"),
feature_feature1_export : new DepConfig(true, true, ":feature:feature1:export"),
lib_base : new DepConfig(true, true, ":lib:base"),
lib_common : new DepConfig(true, true, ":lib:common"),
feature_mock : new DepConfig(false, true , ":feature:mock"),
feature_launcher_app : new DepConfig(true , true , ":feature:launcher:app"),
feature_feature0_app : new DepConfig(false, true , ":feature:feature0:app"),
feature_feature0_pkg : new DepConfig(true , true , ":feature:feature0:pkg", "com.blankj:feature-feature0-pkg:1.0"),
feature_feature0_export : new DepConfig(true , true , ":feature:feature0:export"),
feature_feature1_app : new DepConfig(false, true , ":feature:feature1:app"),
feature_feature1_pkg : new DepConfig(true , true , ":feature:feature1:pkg"),
feature_feature1_export : new DepConfig(true , true , ":feature:feature1:export"),
lib_base : new DepConfig(true , true , ":lib:base"),
lib_common : new DepConfig(true , true , ":lib:common"),
/*Never delete this line*/
// feature_template_app : new DepConfig(":feature:template:app"),
// feature_template_pkg : new DepConfig(":feature:template:pkg"),
// feature_template_export : new DepConfig(":feature:template:export"),
plugin_gradle : new DepConfig(pluginPath: "com.android.tools.build:gradle:3.3.0"),
plugin_kotlin : new DepConfig(pluginPath: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"),
plugin_api : new DepConfig(pluginPath: "com.blankj:api-gradle-plugin:1.1", pluginId: "com.blankj.api"),
plugin_bus : new DepConfig(pluginPath: "com.blankj:bus-gradle-plugin:2.3", pluginId: "com.blankj.bus"),
plugin_gradle : new DepConfig(pluginPath: "com.android.tools.build:gradle:$gradlePluginVersion"),
plugin_kotlin : new DepConfig(pluginPath: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"),
plugin_api : new DepConfig(pluginPath: "com.blankj:api-gradle-plugin:1.2", pluginId: "com.blankj.api"),
plugin_bus : new DepConfig(pluginPath: "com.blankj:bus-gradle-plugin:2.4", pluginId: "com.blankj.bus"),

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

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

leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:$leakcanary_version"),
leakcanary_android_no_op : new DepConfig("com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"),
leakcanary_support_fragment: new DepConfig("com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version"),
leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:2.1"),
]
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/groovy/ConfigUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class ConfigUtils {
def configs = [:]
for (Map.Entry<String, DepConfig> entry : Config.depConfig.entrySet()) {
def (name, config) = [entry.key, entry.value]
if (name.startsWith("plugin_")) {
if (config.pluginPath) {
config.dep = config.pluginPath
} else {
if (config.useLocal) {
config.dep = gradle.rootProject.findProject(config.localPath)
config.dep = gradle.rootProject.findProject(config.projectPath)
} else {
config.dep = config.remotePath
}
Expand All @@ -41,7 +41,7 @@ class ConfigUtils {
if (project.path.contains(":plugin:")) {
return
}
if (project.name == "app") {
if (project.name.endsWith("_app")) {
GLog.l(project.toString() + " applies buildApp.gradle")
project.apply {
from "${project.rootDir.path}/buildApp.gradle"
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/groovy/DepConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class DepConfig {
return splits.length == 3 ? splits[2] : null
}

String getProjectPath() {
return localPath.substring(0, localPath.lastIndexOf(":")) + ":" + localPath.substring(1).replace(":", "_")
}

@Override
String toString() {
return "{ isApply = ${getFlag(isApply)}" +
Expand Down
1 change: 0 additions & 1 deletion lib/base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ dependencies {
api Config.depConfig.support_multidex.dep
api Config.depConfig.support_constraint.dep
api Config.depConfig.kotlin.dep
compileOnly Config.depConfig.leakcanary_android_no_op.dep
}
13 changes: 0 additions & 13 deletions lib/base/src/main/java/com/blankj/base/BaseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ProcessUtils;
import com.squareup.leakcanary.LeakCanary;

import java.util.ArrayList;

Expand All @@ -34,22 +33,10 @@ protected void attachBaseContext(Context base) {
public void onCreate() {
super.onCreate();
sInstance = this;
initLeakCanary();
initLog();
initCrash();
}

private void initLeakCanary() {// 内存泄露检查工具
if (isDebug()) {
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
}
}

// init it in ur application
public void initLog() {
LogUtils.Config config = LogUtils.getConfig()
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ for (def pro in config.proConfig) {

if (pro.useLocal && pro.isApply) {
include pro.localPath
project(pro.localPath).name = pro.localPath.substring(1).replace(":", "_")
}
}

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

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

0 comments on commit daf69bb

Please sign in to comment.