├── .gitignore ├── README.md ├── build.gradle ├── buildApp.gradle ├── buildLib.gradle ├── buildSrc ├── .gitignore ├── build.gradle └── src │ └── main │ └── groovy │ ├── Config.groovy │ ├── ConfigUtils.groovy │ ├── DepConfig.groovy │ ├── GLog.groovy │ └── TaskDurationUtils.groovy ├── config.json ├── feature ├── feature0 │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── blankj │ │ │ └── feature0 │ │ │ └── app │ │ │ └── Feature0App.java │ ├── export │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── blankj │ │ │ └── feature0 │ │ │ └── export │ │ │ └── bean │ │ │ └── Feature0Bean.java │ └── pkg │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── blankj │ │ │ └── feature0 │ │ │ └── pkg │ │ │ ├── BusConifg.java │ │ │ └── main │ │ │ └── Feature0Activity.java │ │ └── res │ │ ├── layout │ │ └── feature0_activity.xml │ │ └── values │ │ └── strings.xml ├── feature1 │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── blankj │ │ │ └── feature1 │ │ │ └── app │ │ │ └── Feature1App.java │ ├── export │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── blankj │ │ │ └── feature1 │ │ │ └── export │ │ │ ├── api │ │ │ └── Feature1Api.java │ │ │ └── bean │ │ │ ├── Feature1Param.java │ │ │ └── Feature1Result.java │ └── pkg │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── blankj │ │ │ └── feature1 │ │ │ └── pkg │ │ │ ├── Feature1ApiImpl.java │ │ │ └── main │ │ │ └── Feature1Activity.java │ │ └── res │ │ ├── layout │ │ └── feature1_activity.xml │ │ └── values │ │ └── strings.xml ├── launcher │ └── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── blankj │ │ └── launcher │ │ └── app │ │ └── LauncherApp.java ├── mock │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── blankj │ │ └── mock │ │ └── feature1 │ │ └── Feature1ApiMock.java └── template │ ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── blankj │ │ └── template │ │ └── app │ │ └── TemplateApp.java │ ├── export │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ └── AndroidManifest.xml │ └── pkg │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── blankj │ │ └── template │ │ └── pkg │ │ └── TemplateActivity.java │ └── res │ ├── layout │ └── template_activity.xml │ └── values │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib ├── base │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── blankj │ │ └── base │ │ ├── BaseActivity.java │ │ └── BaseApplication.java └── common │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── blankj │ │ └── common │ │ ├── CommonApplication.java │ │ ├── CommonBackActivity.java │ │ └── CommonTitleActivity.java │ └── res │ ├── drawable │ └── base_back.png │ ├── layout │ └── common_activity_title.xml │ ├── mipmap-xhdpi │ └── ic_launcher.png │ └── values │ ├── colors.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | local.properties 4 | .idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | *.phrof 11 | __api__.json 12 | __bus__.json 13 | /apk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AucFrame 之简介及学习 2 | 3 | ## 简介 4 | 首先,什么是 AUC 呢?在 QQ 群里的小伙伴们应该知道这个词,或者知道我的工具类的也应该能猜到是什么,没错,AUC 全称就是 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode),这个项目的生命周期已长达 3 年之久,star 数目前是 24k+,应该算是比较成功的一个开源项目了,基于它,我打造了一套自认为还不错的组件化架构 ———— **[AucFrame](https://github.com/Blankj/AucFrameTemplate)**,其优点如下所示: 5 | 6 | * 统一管理项目中的 Gradle 7 | * 自由选择调试模块 8 | * 自由选择需要的包 9 | * 自由切换源码和远程仓库 10 | * 业务模块互不依赖,完全解偶 11 | * 模块间通讯一学就会 12 | * 比 EventBus 更高效的模块内通讯 13 | 14 | 接下来就让我们来一一揭开他的神秘面纱。 15 | 16 | ## 预览 17 | 架构么,肯定要开门见山,直接上图,不然说的再天花乱坠也无济于事,也就是所谓的 `no picture you say a j8`,AucFrame 的架构如下所示: 18 | ![AucFrame](http://ww1.sinaimg.cn/large/b75b8776ly1g5byaor9aej20s10kl0uo.jpg) 19 | 20 | 其项目中具体的工程结构如下所示: 21 | ``` 22 | └── AndroidUtilCode 23 | ├── feature 24 | │ ├── launcher 25 | │ │   └── app 26 | │ ├── main 27 | │ │   ├── app 28 | │ │   └── pkg 29 | │ ├── mock 30 | │ ├── subutil 31 | │ │   ├── app 32 | │ │   ├── export 33 | │ │   └── pkg 34 | │ └── utilcode 35 | │ ├── app 36 | │ ├── export 37 | │ └── pkg 38 | └── lib 39 |    ├── base 40 |    ├── common 41 |    ├── subutil 42 |    └── utilcode 43 | ``` 44 | 45 | 基于此,我们可以设计出如下通用架构: 46 | 47 | ![AucFrameGeneral](http://ww1.sinaimg.cn/large/b75b8776ly1g5byaxfsbuj20s10kptam.jpg) 48 | 49 | 其工程结构如下所示: 50 | ``` 51 | └── ProjectName 52 | ├── feature 53 | │ ├── launcher 54 | │ │   └── app 55 | │ ├── feature0 56 | │ │ ├── app 57 | │ │ ├── export 58 | │ │ └── pkg 59 | │ ├── feature1 60 | │ │   ├── app 61 | │ │   ├── export 62 | │ │   └── pkg 63 | │ └── mock 64 | └── lib 65 |    ├── base 66 |    ├── common 67 |    ├── rxjava 68 |    └── utilcode 69 | ``` 70 | 71 | 对着架构图也许你也能撸出来一个,但其优雅程度肯定不及我撸的,具体如何优雅?最直接的就是 feature 下的所有模块的 `build.gradle` 都是空空如也,没有一行代码,甚至删了也无所谓,也就不需要你写哪个模块具体需要依赖什么,但确切的依赖关系,就是架构中所示,开发者可自由配置想要运行哪个 `app`,自由配置你所需要的 `pkg`,做到各业务可完全独立运行,下面就让我带领你如何优雅地撸出它来。 72 | 73 | 74 | ## 学习 75 | 该教程适合期望能优化自己工程架构的中高级开发人员,新手的话建议把 Gradle 摸清楚了再来学习即可,为了你更好更全面地了解及掌握 AucFrame,在这里我会一步步地搭建一个模板工程:[AucFrameTemplate](https://github.com/Blankj/AucFrameTemplate),并教你如何搭建出该架构及背后的原理,方便你可以运用到你的项目中,或者在下个项目中快速使用,相关课程列表如下所示: 76 | 77 | 0. AucFrame 之简介及学习(就是本节) 78 | 1. AucFrame 之让你的 Gradle 更智能 79 | 2. AucFrame 之统一管理 Gradle 80 | 3. AucFrame 之解放 Gradle 81 | 4. AucFrame 之模块间通信 82 | 5. AucFrame 之模块内通信 83 | 84 | 85 | 欢迎加入我的知识星球「**[基你太美](https://t.zsxq.com/FmeqfYF)**」,我会在星球中分享 [AucFrame](https://blankj.com/2019/07/22/auc-frame/) 框架、大厂面经、[AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode) 更详尽的说明...一切我所了解的知识,你可以通过支付进入我的星球「**[基你太美](https://t.zsxq.com/FmeqfYF)**」进行体验,加入后优先观看星球中精华的部分,如果觉得星球的内容对自身没有收益,你可以自行申请退款退出星球,也没必要加我好友;**如果你已确定要留在我的星球,可以通过扫描如下二维码(备注:基你太美+你的星球昵称)加我个人微信,方便我后续拉你进群(PS:进得越早价格越便宜)。** 86 | 87 | ![我的二维码](https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/wechat.png) -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ConfigUtils.init(gradle) 4 | repositories { 5 | google() 6 | jcenter() 7 | 8 | } 9 | dependencies { 10 | for (def entrySet : ConfigUtils.getApplyPlugins().entrySet()) { 11 | classpath entrySet.value.dep 12 | } 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | google() 19 | jcenter() 20 | 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /buildApp.gradle: -------------------------------------------------------------------------------- 1 | apply { 2 | plugin "com.android.application" 3 | plugin "kotlin-android" 4 | plugin "kotlin-android-extensions" 5 | plugin Config.depConfig.plugin_api.pluginId 6 | plugin Config.depConfig.plugin_bus.pluginId 7 | } 8 | 9 | android { 10 | compileSdkVersion Config.compileSdkVersion 11 | defaultConfig { 12 | minSdkVersion Config.minSdkVersion 13 | versionCode Config.versionCode 14 | versionName Config.versionName 15 | applicationId Config.applicationId + suffix 16 | targetSdkVersion Config.targetSdkVersion 17 | multiDexEnabled true 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | applicationIdSuffix ".debug" 25 | resValue "string", "app_name", Config.appName + suffix + ".debug" 26 | } 27 | 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | resValue "string", "app_name", Config.appName + suffix 32 | } 33 | } 34 | 35 | packagingOptions { 36 | exclude 'META-INF/*' 37 | } 38 | 39 | dexOptions { 40 | preDexLibraries true 41 | javaMaxHeapSize "8g" 42 | maxProcessCount 8 43 | dexInProcess = true 44 | } 45 | } 46 | 47 | dependencies { 48 | // LeakCanary 49 | debugImplementation Config.depConfig.leakcanary_android.dep 50 | 51 | // 根据 Config.pkgConfig 来依赖所有 pkg 52 | for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) { 53 | api entrySet.value.dep 54 | } 55 | 56 | if (Config.depConfig.feature_mock.isApply) { 57 | api Config.depConfig.feature_mock.dep 58 | } 59 | } 60 | 61 | def getSuffix() { 62 | if (project.name == "feature_launcher_app") return "" 63 | return "." + project.name.substring("feature_".length(), project.name.length() - "_app".length()) 64 | } -------------------------------------------------------------------------------- /buildLib.gradle: -------------------------------------------------------------------------------- 1 | apply { 2 | plugin "com.android.library" 3 | plugin "kotlin-android" 4 | plugin "kotlin-android-extensions" 5 | } 6 | 7 | android { 8 | compileSdkVersion Config.compileSdkVersion 9 | 10 | defaultConfig { 11 | minSdkVersion Config.minSdkVersion 12 | versionCode Config.versionCode 13 | versionName Config.versionName 14 | 15 | consumerProguardFiles 'proguard-rules.pro' 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | lintOptions { 26 | abortOnError false 27 | } 28 | } 29 | 30 | dependencies { 31 | if (project.name.endsWith("_pkg") || project.name.endsWith("_mock")) { 32 | // if module's name equals 'pkg', api all of export 33 | for (def entrySet : ConfigUtils.getApplyExports().entrySet()) { 34 | api entrySet.value.dep 35 | } 36 | } else if (project.name.endsWith("_export")) { 37 | api Config.depConfig.lib_common.dep 38 | } 39 | } -------------------------------------------------------------------------------- /buildSrc/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | google() 3 | jcenter() 4 | } 5 | 6 | apply { 7 | plugin 'groovy' 8 | plugin 'java-gradle-plugin' 9 | } 10 | 11 | dependencies { 12 | implementation gradleApi() 13 | implementation localGroovy() 14 | implementation "commons-io:commons-io:2.6" 15 | } -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/Config.groovy: -------------------------------------------------------------------------------- 1 | class Config { 2 | 3 | static applicationId = 'com.blankj.aucframe' // TODO: MODIFY 4 | static appName = 'AucFrame' // TODO: MODIFY 5 | 6 | static compileSdkVersion = 27 // TODO: MODIFY 7 | static minSdkVersion = 21 // TODO: MODIFY 8 | static targetSdkVersion = 27 // TODO: MODIFY 9 | static versionCode = 1_000_000 // TODO: MODIFY 10 | static versionName = '1.0.0'// E.g. 1.9.72 => 1,009,072 // TODO: MODIFY 11 | 12 | static gradlePluginVersion = '3.5.0' 13 | static kotlinVersion = '1.3.50' 14 | static supportVersion = '27.1.1' 15 | 16 | static depConfig = [ 17 | /*Never delete this line*/ 18 | /*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"), 29 | /*Never delete this line*/ 30 | // feature_template_app : new DepConfig(":feature:template:app"), 31 | // feature_template_pkg : new DepConfig(":feature:template:pkg"), 32 | // feature_template_export : new DepConfig(":feature:template:export"), 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"), 37 | 38 | support_appcompat_v7 : new DepConfig("com.android.support:appcompat-v7:$supportVersion"), 39 | support_design : new DepConfig("com.android.support:design:$supportVersion"), 40 | support_multidex : new DepConfig("com.android.support:multidex:1.0.2"), 41 | support_constraint : new DepConfig("com.android.support.constraint:constraint-layout:1.1.3"), 42 | 43 | kotlin : new DepConfig("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"), 44 | utilcode : new DepConfig("com.blankj:utilcode:1.28.0"), 45 | free_proguard : new DepConfig("com.blankj:free-proguard:1.0.1"), 46 | swipe_panel : new DepConfig("com.blankj:swipe-panel:1.1"), 47 | 48 | leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:2.1"), 49 | ] 50 | } -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/ConfigUtils.groovy: -------------------------------------------------------------------------------- 1 | import org.gradle.api.Project 2 | import org.gradle.api.ProjectEvaluationListener 3 | import org.gradle.api.ProjectState 4 | import org.gradle.api.invocation.Gradle 5 | 6 | class ConfigUtils { 7 | 8 | static init(Gradle gradle) { 9 | generateDep(gradle) 10 | addCommonGradle(gradle) 11 | TaskDurationUtils.init(gradle) 12 | } 13 | 14 | /** 15 | * 根据 depConfig 生成 dep 16 | */ 17 | private static void generateDep(Gradle gradle) { 18 | def configs = [:] 19 | for (Map.Entry entry : Config.depConfig.entrySet()) { 20 | def (name, config) = [entry.key, entry.value] 21 | if (config.pluginPath) { 22 | config.dep = config.pluginPath 23 | } else { 24 | if (config.useLocal) { 25 | config.dep = gradle.rootProject.findProject(config.projectPath) 26 | } else { 27 | config.dep = config.remotePath 28 | } 29 | } 30 | configs.put(name, config) 31 | } 32 | GLog.l("generateDep = ${GLog.object2String(configs)}") 33 | } 34 | 35 | private static addCommonGradle(Gradle gradle) { 36 | gradle.addProjectEvaluationListener(new ProjectEvaluationListener() { 37 | @Override 38 | void beforeEvaluate(Project project) { 39 | // 在 project 的 build.gradle 前 do sth. 40 | if (project.subprojects.isEmpty()) { 41 | if (project.path.contains(":plugin:")) { 42 | return 43 | } 44 | if (project.name.endsWith("_app")) { 45 | GLog.l(project.toString() + " applies buildApp.gradle") 46 | project.apply { 47 | from "${project.rootDir.path}/buildApp.gradle" 48 | } 49 | } else { 50 | GLog.l(project.toString() + " applies buildLib.gradle") 51 | project.apply { 52 | from "${project.rootDir.path}/buildLib.gradle" 53 | } 54 | } 55 | } 56 | } 57 | 58 | @Override 59 | void afterEvaluate(Project project, ProjectState state) { 60 | // 在 project 的 build.gradle 末 do sth. 61 | } 62 | }) 63 | } 64 | 65 | static getApplyPlugins() { 66 | def plugins = [:] 67 | for (Map.Entry entry : Config.depConfig.entrySet()) { 68 | if (entry.value.isApply && entry.key.startsWith("plugin_")) { 69 | plugins.put(entry.key, entry.value) 70 | } 71 | } 72 | GLog.d("getApplyPlugins = ${GLog.object2String(plugins)}") 73 | return plugins 74 | } 75 | 76 | static getApplyPkgs() { 77 | def pkgs = [:] 78 | for (Map.Entry entry : Config.depConfig.entrySet()) { 79 | if (entry.value.isApply && entry.key.endsWith("_pkg")) { 80 | pkgs.put(entry.key, entry.value) 81 | } 82 | } 83 | GLog.d("getApplyPkgs = ${GLog.object2String(pkgs)}") 84 | return pkgs 85 | } 86 | 87 | static getApplyExports() { 88 | def exports = [:] 89 | for (Map.Entry entry : Config.depConfig.entrySet()) { 90 | if (entry.value.isApply && entry.key.endsWith("_export")) { 91 | exports.put(entry.key, entry.value) 92 | } 93 | } 94 | GLog.d("getApplyExports = ${GLog.object2String(exports)}") 95 | return exports 96 | } 97 | } -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/DepConfig.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | *
 3 |  *     author: blankj
 4 |  *     blog  : http://blankj.com
 5 |  *     time  : 2019/07/13
 6 |  *     desc  :
 7 |  * 
8 | */ 9 | class DepConfig { 10 | boolean isApply // 是否应用 11 | boolean useLocal // 是否使用本地的 12 | String localPath // 本地路径 13 | String remotePath// 远程路径 14 | String pluginPath// 插件路径 15 | String pluginId // 插件 ID 16 | def dep // 根据条件生成项目最终的依赖项 17 | 18 | DepConfig() { 19 | isApply = true 20 | } 21 | 22 | DepConfig(String path) { 23 | this(true, path) 24 | } 25 | 26 | DepConfig(boolean isApply, String path) { 27 | if (path.startsWith(":")) { 28 | this.useLocal = true 29 | this.localPath = path 30 | this.isApply = isApply 31 | } else { 32 | this.useLocal = false 33 | this.remotePath = path 34 | this.isApply = isApply 35 | } 36 | } 37 | 38 | DepConfig(boolean useLocal, String localPath, String remotePath) { 39 | this(true, useLocal, localPath, remotePath) 40 | } 41 | 42 | DepConfig(boolean isApply, boolean useLocal, String localPath) { 43 | this(isApply, useLocal, localPath, null) 44 | } 45 | 46 | DepConfig(boolean isApply, boolean useLocal, String localPath, String remotePath) { 47 | this.isApply = isApply 48 | this.useLocal = useLocal 49 | this.localPath = localPath 50 | this.remotePath = remotePath 51 | } 52 | 53 | String getPath() { 54 | if (pluginPath != null) return pluginPath 55 | return useLocal ? localPath : remotePath 56 | } 57 | 58 | String getGroupId() { 59 | String[] splits = remotePath.split(":") 60 | return splits.length == 3 ? splits[0] : null 61 | } 62 | 63 | String getArtifactId() { 64 | String[] splits = remotePath.split(":") 65 | return splits.length == 3 ? splits[1] : null 66 | } 67 | 68 | String getVersion() { 69 | String[] splits = remotePath.split(":") 70 | return splits.length == 3 ? splits[2] : null 71 | } 72 | 73 | String getProjectPath() { 74 | return localPath.substring(0, localPath.lastIndexOf(":")) + ":" + localPath.substring(1).replace(":", "_") 75 | } 76 | 77 | @Override 78 | String toString() { 79 | return "{ isApply = ${getFlag(isApply)}" + 80 | ", useLocal = ${getFlag(useLocal)}" + 81 | (dep == null ? ", path = " + path : (", dep = " + dep)) + 82 | " }" 83 | } 84 | 85 | static String getFlag(boolean b) { 86 | return b ? "✅" : "❌" 87 | } 88 | } -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/GLog.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | *
  3 |  *     author: blankj
  4 |  *     blog  : http://blankj.com
  5 |  *     time  : 2019/07/13
  6 |  *     desc  :
  7 |  * 
8 | */ 9 | class GLog { 10 | 11 | def static debugSwitch = true 12 | 13 | static d(Object... contents) { 14 | if (!debugSwitch) return contents 15 | return l(contents) 16 | } 17 | 18 | static l(Object... contents) { 19 | StringBuilder sb = new StringBuilder() 20 | sb.append(LogConst.BORDER_TOP) 21 | sb.append(borderMsg(processContents(contents))) 22 | sb.append(LogConst.BORDER_BTM) 23 | print sb.toString() 24 | return contents 25 | } 26 | 27 | private static borderMsg(String msg) { 28 | StringBuilder sb = new StringBuilder() 29 | object2String(msg).split(LogConst.LINE_SEP).each { line -> 30 | sb.append(LogConst.BORDER_LFT).append(line).append(LogConst.LINE_SEP) 31 | } 32 | return sb 33 | } 34 | 35 | private static processContents(final Object... contents) { 36 | String body = LogConst.NULL 37 | if (contents != null) { 38 | if (contents.length == 1) { 39 | body = object2String(contents[0]) 40 | } else { 41 | StringBuilder sb = new StringBuilder() 42 | int i = 0 43 | for (int len = contents.length; i < len; ++i) { 44 | Object content = contents[i] 45 | sb.append("args[$i] = ") 46 | .append(object2String(content)) 47 | .append(LogConst.LINE_SEP) 48 | } 49 | body = sb.toString() 50 | } 51 | } 52 | return body.length() == 0 ? LogConst.NOTHING : body 53 | } 54 | 55 | static String object2String(Object object) { 56 | if (object == null) return "null"; 57 | if (object.getClass().isArray()) return LogFormatter.array2String(object); 58 | if (object instanceof List) return LogFormatter.list2String(object); 59 | if (object instanceof Map) return LogFormatter.map2String(object); 60 | if (object instanceof Throwable) return LogFormatter.throwable2String(object); 61 | return object.toString(); 62 | } 63 | 64 | static class LogFormatter { 65 | 66 | private static array2String(Object object) { 67 | if (object instanceof Object[]) { 68 | return Arrays.deepToString((Object[]) object); 69 | } else if (object instanceof boolean[]) { 70 | return Arrays.toString((boolean[]) object); 71 | } else if (object instanceof byte[]) { 72 | return Arrays.toString((byte[]) object); 73 | } else if (object instanceof char[]) { 74 | return Arrays.toString((char[]) object); 75 | } else if (object instanceof double[]) { 76 | return Arrays.toString((double[]) object); 77 | } else if (object instanceof float[]) { 78 | return Arrays.toString((float[]) object); 79 | } else if (object instanceof int[]) { 80 | return Arrays.toString((int[]) object); 81 | } else if (object instanceof long[]) { 82 | return Arrays.toString((long[]) object); 83 | } else if (object instanceof short[]) { 84 | return Arrays.toString((short[]) object); 85 | } 86 | throw new IllegalArgumentException("Array has incompatible type: " + object.getClass()); 87 | } 88 | 89 | private static list2String(List list) { 90 | StringBuilder sb = new StringBuilder() 91 | sb.append("[") 92 | list.each { v -> 93 | if (v instanceof Map || v instanceof List) { 94 | sb.append(String.format("$LogConst.LINE_SEP%${deep++ * 8}s${object2String(v)},", "")) 95 | deep-- 96 | } else { 97 | sb.append(String.format("$LogConst.LINE_SEP%${deep * 8}s$v,", "")) 98 | } 99 | } 100 | sb.deleteCharAt(sb.length() - 1) 101 | if (deep - 1 == 0) { 102 | sb.append("$LogConst.LINE_SEP]") 103 | } else { 104 | sb.append(String.format("$LogConst.LINE_SEP%${(deep - 1) * 8}s]", "")) 105 | } 106 | return sb.toString() 107 | } 108 | 109 | private static deep = 1; 110 | 111 | private static map2String(Map map) { 112 | StringBuilder sb = new StringBuilder() 113 | sb.append("[") 114 | map.each { k, v -> 115 | if (v instanceof Map || v instanceof List) { 116 | sb.append(String.format("$LogConst.LINE_SEP%${deep++ * 8}s%-26s: ${object2String(v)},", "", k)) 117 | deep-- 118 | } else { 119 | sb.append(String.format("$LogConst.LINE_SEP%${deep * 8}s%-26s: $v,", "", k)) 120 | } 121 | } 122 | sb.deleteCharAt(sb.length() - 1) 123 | if (deep - 1 == 0) { 124 | sb.append("$LogConst.LINE_SEP]") 125 | } else { 126 | sb.append(String.format("$LogConst.LINE_SEP%${(deep - 1) * 8}s]", "")) 127 | } 128 | return sb.toString() 129 | } 130 | 131 | private static throwable2String(Throwable throwable) { 132 | final List throwableList = new ArrayList<>(); 133 | while (throwable != null && !throwableList.contains(throwable)) { 134 | throwableList.add(throwable); 135 | throwable = throwable.getCause(); 136 | } 137 | final int size = throwableList.size(); 138 | final List frames = new ArrayList<>(); 139 | List nextTrace = getStackFrameList(throwableList.get(size - 1)); 140 | for (int i = size; --i >= 0;) { 141 | final List trace = nextTrace; 142 | if (i != 0) { 143 | nextTrace = getStackFrameList(throwableList.get(i - 1)); 144 | removeCommonFrames(trace, nextTrace); 145 | } 146 | if (i == size - 1) { 147 | frames.add(throwableList.get(i).toString()); 148 | } else { 149 | frames.add(" Caused by: " + throwableList.get(i).toString()); 150 | } 151 | frames.addAll(trace); 152 | } 153 | StringBuilder sb = new StringBuilder(); 154 | for (final String element : frames) { 155 | sb.append(element).append(LogConst.LINE_SEP); 156 | } 157 | return sb.toString(); 158 | } 159 | 160 | private static List getStackFrameList(final Throwable throwable) { 161 | final StringWriter sw = new StringWriter(); 162 | final PrintWriter pw = new PrintWriter(sw, true); 163 | throwable.printStackTrace(pw); 164 | final String stackTrace = sw.toString(); 165 | final StringTokenizer frames = new StringTokenizer(stackTrace, LogConst.LINE_SEP); 166 | final List list = new ArrayList<>(); 167 | boolean traceStarted = false; 168 | while (frames.hasMoreTokens()) { 169 | final String token = frames.nextToken(); 170 | // Determine if the line starts with at 171 | final int at = token.indexOf("at"); 172 | if (at != -1 && token.substring(0, at).trim().isEmpty()) { 173 | traceStarted = true; 174 | list.add(token); 175 | } else if (traceStarted) { 176 | break; 177 | } 178 | } 179 | return list; 180 | } 181 | 182 | private static void removeCommonFrames(final List causeFrames, final List wrapperFrames) { 183 | int causeFrameIndex = causeFrames.size() - 1; 184 | int wrapperFrameIndex = wrapperFrames.size() - 1; 185 | while (causeFrameIndex >= 0 && wrapperFrameIndex >= 0) { 186 | // Remove the frame from the cause trace if it is the same 187 | // as in the wrapper trace 188 | final String causeFrame = causeFrames.get(causeFrameIndex); 189 | final String wrapperFrame = wrapperFrames.get(wrapperFrameIndex); 190 | if (causeFrame.equals(wrapperFrame)) { 191 | causeFrames.remove(causeFrameIndex); 192 | } 193 | causeFrameIndex--; 194 | wrapperFrameIndex--; 195 | } 196 | } 197 | } 198 | 199 | static class LogConst { 200 | static LINE_SEP = System.getProperty("line.separator"); 201 | static BORDER_TOP = "┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────" + LINE_SEP 202 | static BORDER_LFT = "│ "; 203 | static BORDER_BTM = "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────" + LINE_SEP 204 | 205 | static final NOTHING = "log nothing"; 206 | static final NULL = "null"; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/TaskDurationUtils.groovy: -------------------------------------------------------------------------------- 1 | import org.gradle.BuildListener 2 | import org.gradle.BuildResult 3 | import org.gradle.api.Task 4 | import org.gradle.api.execution.TaskExecutionListener 5 | import org.gradle.api.initialization.Settings 6 | import org.gradle.api.invocation.Gradle 7 | import org.gradle.api.tasks.TaskState 8 | 9 | import java.text.SimpleDateFormat 10 | 11 | /** 12 | *
13 |  *     author: blankj
14 |  *     blog  : http://blankj.com
15 |  *     time  : 2019/11/22
16 |  *     desc  :
17 |  * 
18 | */ 19 | class TaskDurationUtils { 20 | 21 | static List taskInfoList = [] 22 | static long startMillis 23 | 24 | static init(Gradle grd) { 25 | startMillis = System.currentTimeMillis() 26 | grd.addListener(new TaskExecutionListener() { 27 | @Override 28 | void beforeExecute(Task task) { 29 | task.ext.startTime = System.currentTimeMillis() 30 | } 31 | 32 | @Override 33 | void afterExecute(Task task, TaskState state) { 34 | def exeDuration = System.currentTimeMillis() - task.ext.startTime 35 | if (exeDuration >= 100) { 36 | taskInfoList.add(new TaskInfo(task: task, exeDuration: exeDuration)) 37 | } 38 | } 39 | }) 40 | grd.addBuildListener(new BuildListener() { 41 | @Override 42 | void buildStarted(Gradle gradle) {} 43 | 44 | @Override 45 | void settingsEvaluated(Settings settings) {} 46 | 47 | @Override 48 | void projectsLoaded(Gradle gradle) {} 49 | 50 | @Override 51 | void projectsEvaluated(Gradle gradle) {} 52 | 53 | @Override 54 | void buildFinished(BuildResult buildResult) { 55 | if (!taskInfoList.isEmpty()) { 56 | Collections.sort(taskInfoList, new Comparator() { 57 | @Override 58 | int compare(TaskInfo t, TaskInfo t1) { 59 | return t1.exeDuration - t.exeDuration 60 | } 61 | }) 62 | StringBuilder sb = new StringBuilder() 63 | int buildSec = (System.currentTimeMillis() - startMillis) / 1000; 64 | int m = buildSec / 60; 65 | int s = buildSec % 60; 66 | def timeInfo = (m == 0 ? "${s}s" : "${m}m ${s}s (${buildSec}s)") 67 | sb.append("BUILD FINISHED in $timeInfo\n") 68 | taskInfoList.each { 69 | sb.append(String.format("%7sms %s\n", it.exeDuration, it.task.path)) 70 | } 71 | def content = sb.toString() 72 | GLog.d(content) 73 | File file = new File(grd.rootProject.buildDir.getAbsolutePath(), 74 | "build_time_records_" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".txt") 75 | file.getParentFile().mkdirs() 76 | file.write(content) 77 | } 78 | } 79 | }) 80 | } 81 | 82 | private static class TaskInfo { 83 | Task task 84 | long exeDuration 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appConfigDesc": "appConfig 配置的是可以跑 app 的模块,git 提交务必只包含 launcher", 3 | "appConfig": ["launcher"], 4 | "pkgConfigDesc": "pkgConfig 配置的是要依赖的功能包,为空则依赖全部,git 提交务必为空", 5 | "pkgConfig": [], 6 | "proConfigDesc": "proConfig 配置的是使用本地还是仓库,优先级低于 appConfig 和 pkgConfig", 7 | "proConfig": [ 8 | {"isApply": true, "useLocal": true, "localPath": ":feature:mock"}, 9 | {"isApply": true, "useLocal": true, "localPath": ":feature:launcher:app"}, 10 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature0:app"}, 11 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature0:pkg", "remotePath": "com.blankj:feature-feature0-pkg:1.0"}, 12 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature0:export"}, 13 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature1:app"}, 14 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature1:pkg"}, 15 | {"isApply": true, "useLocal": true, "localPath": ":feature:feature1:export"}, 16 | {"isApply": true, "useLocal": true, "localPath": ":lib:base"}, 17 | {"isApply": true, "useLocal": true, "localPath": ":lib:common"} 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /feature/feature0/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /feature/feature0/app/build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blankj/AucFrameTemplate/daf69bbc881732f57b636a2834638f855b7e90a9/feature/feature0/app/build.gradle -------------------------------------------------------------------------------- /feature/feature0/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /feature/feature0/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /feature/feature0/app/src/main/java/com/blankj/feature0/app/Feature0App.java: -------------------------------------------------------------------------------- 1 | package com.blankj.feature0.app; 2 | 3 | import com.blankj.common.CommonApplication; 4 | 5 | 6 | public class Feature0App extends CommonApplication { 7 | } 8 | -------------------------------------------------------------------------------- /feature/feature0/export/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /feature/feature0/export/build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blankj/AucFrameTemplate/daf69bbc881732f57b636a2834638f855b7e90a9/feature/feature0/export/build.gradle -------------------------------------------------------------------------------- /feature/feature0/export/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /feature/feature0/export/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /feature/feature0/export/src/main/java/com/blankj/feature0/export/bean/Feature0Bean.java: -------------------------------------------------------------------------------- 1 | package com.blankj.feature0.export.bean; 2 | 3 | 4 | public class Feature0Bean { 5 | } 6 | -------------------------------------------------------------------------------- /feature/feature0/pkg/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /feature/feature0/pkg/build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blankj/AucFrameTemplate/daf69bbc881732f57b636a2834638f855b7e90a9/feature/feature0/pkg/build.gradle -------------------------------------------------------------------------------- /feature/feature0/pkg/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /feature/feature0/pkg/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /feature/feature0/pkg/src/main/java/com/blankj/feature0/pkg/BusConifg.java: -------------------------------------------------------------------------------- 1 | package com.blankj.feature0.pkg; 2 | 3 | 4 | public class BusConifg { 5 | public static final String FEATURE0_SHOW_TOAST = "feature0_show_toast"; 6 | } 7 | -------------------------------------------------------------------------------- /feature/feature0/pkg/src/main/java/com/blankj/feature0/pkg/main/Feature0Activity.java: -------------------------------------------------------------------------------- 1 | package com.blankj.feature0.pkg.main; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.View; 6 | 7 | import com.blankj.common.CommonTitleActivity; 8 | import com.blankj.feature0.pkg.BusConifg; 9 | import com.blankj.feature0.pkg.R; 10 | import com.blankj.feature1.export.api.Feature1Api; 11 | import com.blankj.feature1.export.bean.Feature1Param; 12 | import com.blankj.feature1.export.bean.Feature1Result; 13 | import com.blankj.utilcode.util.ApiUtils; 14 | import com.blankj.utilcode.util.BusUtils; 15 | import com.blankj.utilcode.util.ToastUtils; 16 | 17 | 18 | public class Feature0Activity extends CommonTitleActivity { 19 | 20 | @BusUtils.Bus(tag = BusConifg.FEATURE0_SHOW_TOAST) 21 | public void showToast(String msg) { 22 | ToastUtils.showLong(msg); 23 | } 24 | 25 | @Override 26 | public CharSequence bindTitle() { 27 | return getString(R.string.feature0_title); 28 | } 29 | 30 | @Override 31 | public boolean isSwipeBack() { 32 | return false; 33 | } 34 | 35 | @Override 36 | public int bindLayout() { 37 | return R.layout.feature0_activity; 38 | } 39 | 40 | @Override 41 | public void initView(@Nullable Bundle savedInstanceState, @Nullable View contentView) { 42 | findViewById(R.id.startFeature1Btn).setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View v) { 45 | Feature1Result result = ApiUtils.getApi(Feature1Api.class) 46 | .startFeature1Activity(Feature0Activity.this, new Feature1Param("Feature1Param")); 47 | ToastUtils.showLong(result.getName()); 48 | } 49 | }); 50 | BusUtils.register(this); 51 | findViewById(R.id.showBusToast).setOnClickListener(new View.OnClickListener() { 52 | @Override 53 | public void onClick(View v) { 54 | BusUtils.post(BusConifg.FEATURE0_SHOW_TOAST, "show toast."); 55 | } 56 | }); 57 | } 58 | 59 | @Override 60 | public void doBusiness() { 61 | 62 | } 63 | 64 | @Override 65 | protected void onDestroy() { 66 | super.onDestroy(); 67 | BusUtils.unregister(this); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /feature/feature0/pkg/src/main/res/layout/feature0_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |