├── .gitignore ├── .idea ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── allure │ │ └── modularization │ │ ├── MyApplication.java │ │ └── SplashActivity.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ └── app_activity_splash.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── base ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── allure │ │ └── base │ │ └── application │ │ ├── ApplicationImpl.java │ │ ├── BaseApplication.java │ │ └── ModulesApplicationConfig.java │ └── res │ └── values │ └── strings.xml ├── build.gradle ├── common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── assets │ └── schame_inchat.html │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── allure │ │ │ └── common │ │ │ ├── ARouterManager.java │ │ │ ├── ARouterPathConfig.java │ │ │ ├── SchameFilterActivity.java │ │ │ └── bean │ │ │ └── LoginInfoBean.java │ └── res │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── provider │ └── java │ └── com │ └── allure │ └── provider │ └── ILoginProvider.java ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── login2 └── build │ └── intermediates │ └── incremental │ └── compileDebugAidl │ └── dependency.store ├── modules ├── login │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── allure │ │ │ └── login │ │ │ ├── LoginActivity.java │ │ │ ├── LoginInterceptor.java │ │ │ ├── LoginProviderImpl.java │ │ │ └── application │ │ │ └── LoginApplication.java │ │ └── res │ │ ├── layout │ │ └── login_activity_start.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── main │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── allure │ │ │ └── main │ │ │ ├── MainActivity.java │ │ │ └── MainSecoendActivity.java │ │ └── res │ │ ├── layout │ │ ├── main_activity_second.xml │ │ └── main_activity_start.xml │ │ └── values │ │ └── strings.xml └── shop │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── allure │ │ └── shop │ │ ├── ShopActivity.java │ │ └── application │ │ └── ShopApplication.java │ └── res │ ├── layout │ └── shop_activity_start.xml │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 23 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Android Lint 43 | 44 | 45 | Data flow issuesJava 46 | 47 | 48 | Groovy 49 | 50 | 51 | Initialization issuesJava 52 | 53 | 54 | Java 55 | 56 | 57 | Serialization issuesJava 58 | 59 | 60 | Threading issuesGroovy 61 | 62 | 63 | Threading issuesJava 64 | 65 | 66 | 67 | 68 | Android Lint 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 80 | 81 | 82 | 83 | 84 | 1.8 85 | 86 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AndroidComponentDemo 2 | 3 | Android组件化,插件自动完成依赖特性 4 | 5 | 6 | 7 | [ComponentPlugin](https://github.com/Allure0/AndroidComponentPlugin) 8 | 9 | |自动完成特性 |含义| 10 | | :--------: | :-----: | 11 | | 组件单独运行 | 如何将一个庞大的项目分而治之,可单独运行和集成为一个整体 | 12 | | UI跳转 | 每个业务组件之间如何跳转 | 13 | | 组件通信 | 如何在业务之间进行数据传递 | 14 | | 代码隔离 | 组件与组件之间如何避免直接引用 | 15 | 16 | ## 插件使用方式 17 | 18 | ### Step1:整个项目build.gralde之下添加以下代码 19 | 20 | ``` 21 | /**--引用插件----**/ 22 | apply plugin: 'com.allure.appconfig' 23 | 24 | buildscript { 25 | repositories { 26 | maven { 27 | url "http://dl.bintray.com/allure0/maven" 28 | } 29 | } 30 | dependencies { 31 | //格式为-->group:module:version 32 | classpath 'com.allure.plugin:Component:1.0.0' 33 | } 34 | } 35 | /**--引用插件----**/ 36 | 37 | /**--插件配置宿主壳App与组件----**/ 38 | hostAppConfig { 39 | isDebug true 40 | 41 | //宿主载体 42 | apps { 43 | app { 44 | 45 | mainActivity "com.allure.modularization.SplashActivity" 46 | modules ':modules:login', 47 | ':modules:shop', 48 | ':modules:main' 49 | } 50 | } 51 | 52 | //组件 53 | modules { 54 | login { 55 | isRunAlone true 56 | name ":modules:login" 57 | applicationId "com.allure.login" 58 | mainActivity ".LoginActivity" 59 | 60 | } 61 | shop { 62 | isRunAlone false 63 | name ":modules:shop" 64 | applicationId "com.allure.shop" 65 | mainActivity ".ShopActivity" 66 | 67 | } 68 | main { 69 | isRunAlone false 70 | name ":modules:main" 71 | applicationId "com.allure.main" 72 | mainActivity ".MainActivity" 73 | 74 | } 75 | } 76 | } 77 | /**--插件配置宿主壳App与组件----**/ 78 | ``` 79 | ### Step2:在每一个组件的build.gradle下定义插件的引用 80 | ``` 81 | apply plugin: 'com.allure.appmodules' 82 | ``` 83 | 84 | ## 插件解释 85 | 86 | ##### hostAppConfig: 87 | 88 | | hostAppConfig |解释| 89 | | :--------: | :-----: | 90 | | isDebug | 是否开启debug模式,只有当isDebug为true时,modules的isRunAlone才能生效。同时注意更改此属性后需要清除app的壳工程app的缓存在运行 | 91 | | apps | 壳工程列表,可以有多个壳工程 | 92 | | modules | 各个组件Lib | 93 | 94 | 95 | ##### app: 96 | 97 | | app |解释| 98 | | :--------: | :-----: | 99 | | modules | 依赖的组件列表 | 100 | | applicationId | 启动的application,可默认为空,在测试微信支付分享时可以动态配置使用测试 | 101 | | mainActivity | 启动Activity | 102 | 103 | ##### Modules: 104 | 105 | | app |解释| 106 | | :--------: | :-----: | 107 | | name | 依赖的组件列表 | 108 | | isRunAlone | 是否可以单独运行(必须在isDebug=true情况下可运行) | 109 | | applicationId | 启动的application,必须设置 | 110 | | mainActivity | 启动Activity | 111 | 112 | 113 | [具体插件使用以及具体分析请查看Demo](https://www.jianshu.com/p/23b0239c45aa) 114 | 115 | **Tips:注意isDebug更改后一定要清除app的缓存在重新sync and run** 116 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | //apply plugin: 'com.android.application' 2 | apply plugin: 'com.allure.appmodules' 3 | 4 | 5 | android { 6 | 7 | compileSdkVersion rootProject.ext.defaultConfig.compileSdkVersion 8 | defaultConfig { 9 | applicationId "com.allure.modularization" 10 | minSdkVersion rootProject.ext.defaultConfig.minSdkVersion 11 | targetSdkVersion rootProject.ext.defaultConfig.targetSdkVersion 12 | versionCode rootProject.ext.defaultConfig.versionCode 13 | versionName rootProject.ext.defaultConfig.versionName 14 | javaCompileOptions { 15 | annotationProcessorOptions { 16 | arguments = [moduleName: project.getName()] 17 | } 18 | } 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | lintOptions { 27 | abortOnError false 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | api project(':base') 34 | //ARouter 35 | implementation rootProject.ext.dependencies.arouter_api 36 | annotationProcessor rootProject.ext.dependencies.arouter_compiler 37 | 38 | 39 | 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/allure/modularization/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.allure.modularization; 2 | 3 | import com.allure.base.application.BaseApplication; 4 | 5 | /** 6 | *

描述:(这里用一句话描述这个类的作用)

7 | * Created by Cherish on 2018/8/22.
8 | */ 9 | public class MyApplication extends BaseApplication { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/allure/modularization/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.allure.modularization; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import com.allure.common.ARouterManager; 8 | 9 | public class SplashActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | } 16 | 17 | public void go(View view){ 18 | ARouterManager.start2Main(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |