From daf69bbc881732f57b636a2834638f855b7e90a9 Mon Sep 17 00:00:00 2001 From: Blankj Date: Wed, 8 Apr 2020 03:48:05 +0800 Subject: [PATCH] =?UTF-8?q?AucFrame=20=E4=B9=8B=E4=BA=9B=E8=AE=B8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildAPP.gradle => buildApp.gradle | 10 ++-- buildLib.gradle | 4 +- buildSrc/src/main/groovy/Config.groovy | 46 +++++++++---------- buildSrc/src/main/groovy/ConfigUtils.groovy | 6 +-- buildSrc/src/main/groovy/DepConfig.groovy | 4 ++ lib/base/build.gradle | 1 - .../java/com/blankj/base/BaseApplication.java | 13 ------ settings.gradle | 4 +- 8 files changed, 38 insertions(+), 50 deletions(-) rename buildAPP.gradle => buildApp.gradle (80%) diff --git a/buildAPP.gradle b/buildApp.gradle similarity index 80% rename from buildAPP.gradle rename to buildApp.gradle index 5f59674..d97245e 100644 --- a/buildAPP.gradle +++ b/buildApp.gradle @@ -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 { @@ -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()) { @@ -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()) } \ No newline at end of file diff --git a/buildLib.gradle b/buildLib.gradle index 6137622..4573c3c 100644 --- a/buildLib.gradle +++ b/buildLib.gradle @@ -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 } } \ No newline at end of file diff --git a/buildSrc/src/main/groovy/Config.groovy b/buildSrc/src/main/groovy/Config.groovy index 15e3383..d3118b4 100644 --- a/buildSrc/src/main/groovy/Config.groovy +++ b/buildSrc/src/main/groovy/Config.groovy @@ -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"), ] } \ No newline at end of file diff --git a/buildSrc/src/main/groovy/ConfigUtils.groovy b/buildSrc/src/main/groovy/ConfigUtils.groovy index 9411b2d..1073c9a 100644 --- a/buildSrc/src/main/groovy/ConfigUtils.groovy +++ b/buildSrc/src/main/groovy/ConfigUtils.groovy @@ -18,11 +18,11 @@ class ConfigUtils { def configs = [:] for (Map.Entry 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 } @@ -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" diff --git a/buildSrc/src/main/groovy/DepConfig.groovy b/buildSrc/src/main/groovy/DepConfig.groovy index a50596e..a6c0dac 100644 --- a/buildSrc/src/main/groovy/DepConfig.groovy +++ b/buildSrc/src/main/groovy/DepConfig.groovy @@ -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)}" + diff --git a/lib/base/build.gradle b/lib/base/build.gradle index 81a4b64..219f273 100644 --- a/lib/base/build.gradle +++ b/lib/base/build.gradle @@ -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 } \ No newline at end of file diff --git a/lib/base/src/main/java/com/blankj/base/BaseApplication.java b/lib/base/src/main/java/com/blankj/base/BaseApplication.java index 216334a..9a6f4d3 100644 --- a/lib/base/src/main/java/com/blankj/base/BaseApplication.java +++ b/lib/base/src/main/java/com/blankj/base/BaseApplication.java @@ -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; @@ -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() diff --git a/settings.gradle b/settings.gradle index e8f3aaa..4693428 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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(":", "_") } } @@ -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')