Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Blankj/AucFrameTemplate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4
Choose a base ref
...
head repository: Blankj/AucFrameTemplate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 18 commits
  • 21 files changed
  • 3 contributors

Commits on Jul 21, 2019

  1. AucFrame 之模块内通信

    Blankj committed Jul 21, 2019
    Copy the full SHA
    5ea5aef View commit details

Commits on Jul 22, 2019

  1. AucFrame 之模块内通信

    Blankj committed Jul 22, 2019
    Copy the full SHA
    a9f40bc View commit details
  2. AucFrame 之模块内通信

    Blankj committed Jul 22, 2019
    Copy the full SHA
    e246fd5 View commit details
  3. AucFrame 之模块内通信

    Blankj committed Jul 22, 2019
    Copy the full SHA
    b923928 View commit details

Commits on Jul 23, 2019

  1. AucFrame 之模块内通信

    Blankj committed Jul 23, 2019
    Copy the full SHA
    7898caa View commit details

Commits on Jul 24, 2019

  1. update README

    Blankj committed Jul 24, 2019
    Copy the full SHA
    14fa866 View commit details

Commits on Jul 25, 2019

  1. update README

    Blankj committed Jul 25, 2019
    Copy the full SHA
    6118b36 View commit details

Commits on Jul 31, 2019

  1. update README

    Blankj committed Jul 31, 2019
    Copy the full SHA
    b314a55 View commit details

Commits on Aug 5, 2019

  1. update README

    Blankj committed Aug 5, 2019
    Copy the full SHA
    615562a View commit details
  2. update README

    Blankj committed Aug 5, 2019
    Copy the full SHA
    866b9b1 View commit details

Commits on Aug 8, 2019

  1. update buildApp.gradle

    Blankj committed Aug 8, 2019
    Copy the full SHA
    e554ff6 View commit details
  2. update README

    Blankj committed Aug 8, 2019
    Copy the full SHA
    2f30ea4 View commit details

Commits on Aug 15, 2019

  1. see 08/15 log

    Blankj committed Aug 15, 2019
    Copy the full SHA
    ea0cf4b View commit details

Commits on Oct 12, 2019

  1. update README.md

    Blankj committed Oct 12, 2019
    Copy the full SHA
    dcd9ed0 View commit details

Commits on Nov 1, 2019

  1. Copy the full SHA
    9698e2f View commit details
  2. Merge pull request #4 from gavinliu/master

    fix: can not launch feature app
    Blankj authored Nov 1, 2019
    Copy the full SHA
    e23144e View commit details

Commits on Nov 23, 2019

  1. Copy the full SHA
    ae83a12 View commit details

Commits on Apr 12, 2020

  1. AucFrame 之些许优化

    Blankj committed Apr 12, 2020
    Copy the full SHA
    daf69bb View commit details
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# AucFrame 之简介及学习

## 简介
首先,什么是 AUC 呢?在 QQ 群里的小伙伴们应该知道这个词,或者知道我的工具类的也应该能猜到是什么,没错,AUC 全称就是 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode),这个项目的生命周期已长达 3 年之久,star 数目前是 24k+,应该算是比较成功的一个开源项目了,基于它,我打造了一套自认为还不错的组件化架构 ———— **[AucFrame](https://github.com/Blankj/AucFrameTemplate)**,其优点如下所示:

* 统一管理项目中的 Gradle
* 自由选择调试模块
* 自由选择需要的包
* 自由切换源码和远程仓库
* 业务模块互不依赖,完全解偶
* 模块间通讯一学就会
* 比 EventBus 更高效的模块内通讯

接下来就让我们来一一揭开他的神秘面纱。

## 预览
架构么,肯定要开门见山,直接上图,不然说的再天花乱坠也无济于事,也就是所谓的 `no picture you say a j8`,AucFrame 的架构如下所示:
![AucFrame](http://ww1.sinaimg.cn/large/b75b8776ly1g5byaor9aej20s10kl0uo.jpg)

其项目中具体的工程结构如下所示:
```
└── AndroidUtilCode
├── feature
│ ├── launcher
│ │   └── app
│ ├── main
│ │   ├── app
│ │   └── pkg
│ ├── mock
│ ├── subutil
│ │   ├── app
│ │   ├── export
│ │   └── pkg
│ └── utilcode
│ ├── app
│ ├── export
│ └── pkg
└── lib
   ├── base
   ├── common
   ├── subutil
   └── utilcode
```

基于此,我们可以设计出如下通用架构:

![AucFrameGeneral](http://ww1.sinaimg.cn/large/b75b8776ly1g5byaxfsbuj20s10kptam.jpg)

其工程结构如下所示:
```
└── ProjectName
├── feature
│ ├── launcher
│ │   └── app
│ ├── feature0
│ │ ├── app
│ │ ├── export
│ │ └── pkg
│ ├── feature1
│ │   ├── app
│ │   ├── export
│ │   └── pkg
│ └── mock
└── lib
   ├── base
   ├── common
   ├── rxjava
   └── utilcode
```

对着架构图也许你也能撸出来一个,但其优雅程度肯定不及我撸的,具体如何优雅?最直接的就是 feature 下的所有模块的 `build.gradle` 都是空空如也,没有一行代码,甚至删了也无所谓,也就不需要你写哪个模块具体需要依赖什么,但确切的依赖关系,就是架构中所示,开发者可自由配置想要运行哪个 `app`,自由配置你所需要的 `pkg`,做到各业务可完全独立运行,下面就让我带领你如何优雅地撸出它来。


## 学习
该教程适合期望能优化自己工程架构的中高级开发人员,新手的话建议把 Gradle 摸清楚了再来学习即可,为了你更好更全面地了解及掌握 AucFrame,在这里我会一步步地搭建一个模板工程:[AucFrameTemplate](https://github.com/Blankj/AucFrameTemplate),并教你如何搭建出该架构及背后的原理,方便你可以运用到你的项目中,或者在下个项目中快速使用,相关课程列表如下所示:

0. AucFrame 之简介及学习(就是本节)
1. AucFrame 之让你的 Gradle 更智能
2. AucFrame 之统一管理 Gradle
3. AucFrame 之解放 Gradle
4. AucFrame 之模块间通信
5. AucFrame 之模块内通信


欢迎加入我的知识星球「**[基你太美](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:进得越早价格越便宜)。**

![我的二维码](https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/wechat.png)
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
ConfigUtils.init(gradle)
repositories {
google()
jcenter()
20 changes: 11 additions & 9 deletions buildAPP.gradle → buildApp.gradle
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ apply {
plugin "com.android.application"
plugin "kotlin-android"
plugin "kotlin-android-extensions"
plugin "com.blankj.api"
plugin Config.depConfig.plugin_api.pluginId
plugin Config.depConfig.plugin_bus.pluginId
}

android {
@@ -14,17 +15,20 @@ android {
applicationId Config.applicationId + suffix
targetSdkVersion Config.targetSdkVersion
multiDexEnabled true
resValue "string", "app_name", Config.appName + suffix
}

buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
resValue "string", "app_name", Config.appName + suffix + ".debug"
}

release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "app_name", Config.appName + suffix
}
}

@@ -42,21 +46,19 @@ android {

dependencies {
// LeakCanary
debugImplementation Config.depConfig.leakcanary.android.dep
debugImplementation Config.depConfig.leakcanary.support_fragment.dep
releaseImplementation Config.depConfig.leakcanary.android_no_op.dep
debugImplementation Config.depConfig.leakcanary_android.dep

// 根据 Config.pkgConfig 来依赖所有 pkg
for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) {
api entrySet.value.dep
}

if (Config.depConfig.feature.mock.isApply) {
api Config.depConfig.feature.mock.dep
if (Config.depConfig.feature_mock.isApply) {
api Config.depConfig.feature_mock.dep
}
}

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())
}
6 changes: 3 additions & 3 deletions buildLib.gradle
Original file line number Diff line number Diff line change
@@ -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') {
api Config.depConfig.lib.common.dep
} else if (project.name.endsWith("_export")) {
api Config.depConfig.lib_common.dep
}
}
96 changes: 35 additions & 61 deletions buildSrc/src/main/groovy/Config.groovy
Original file line number Diff line number Diff line change
@@ -9,68 +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.10'
static support_version = '27.1.1'
static leakcanary_version = '1.6.3'

// appConfig 配置的是可以跑 app 的模块,git 提交务必只包含 launcher
static appConfig = ['launcher']
// pkgConfig 配置的是要依赖的功能包,为空则依赖全部,git 提交务必为空
static pkgConfig = []
static gradlePluginVersion = '3.5.0'
static kotlinVersion = '1.3.50'
static supportVersion = '27.1.1'

static depConfig = [
plugin : [
gradle: new DepConfig("com.android.tools.build:gradle:3.3.0"),
kotlin: new DepConfig("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"),
api : new DepConfig("com.blankj:api-gradle-plugin:1.0"),
],

feature : [
mock : new DepConfig(":feature:mock"),

launcher: [
app: new DepConfig(":feature:launcher:app")
],

feature0: [
app : new DepConfig(":feature:feature0:app"),
pkg : new DepConfig(true, ":feature:feature0:pkg", "com.blankj:feature-feature0-pkg:1.0", true),
export: new DepConfig(":feature:feature0:export"),
],

feature1: [
app : new DepConfig(":feature:feature1:app"),
pkg : new DepConfig(":feature:feature1:pkg"),
export: new DepConfig(":feature:feature1:export"),
],

// template: [
// app : new DepConfig(":feature:template:app"),
// pkg : new DepConfig(":feature:template:pkg"),
// export: new DepConfig(":feature:template:export"),
// ],
],

lib : [
base : new DepConfig(":lib:base"),
common: new DepConfig(":lib:common"),
],

support : [
appcompat_v7: new DepConfig("com.android.support:appcompat-v7:$support_version"),
design : new DepConfig("com.android.support:design:$support_version"),
multidex : new DepConfig("com.android.support:multidex:1.0.2"),
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.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"),
android_no_op : new DepConfig("com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"),
support_fragment: new DepConfig("com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version"),
],
/*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"),
/*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:$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:$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:$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:2.1"),
]
}
Loading