升级框架1.0.8,提升稳定性,兼容极端场景

This commit is contained in:
刘彦明
2020-05-28 20:55:18 +08:00
parent 025ffd523d
commit b712b2bce5
16 changed files with 61 additions and 39 deletions

View File

@@ -19,6 +19,8 @@ README: [English](https://github.com/YummyLau/ComponentPlugin/blob/master/README
* 提供更人性化的调试日志格式 * 提供更人性化的调试日志格式
* 2019/12/09 * 2019/12/09
* 优化插件 gradle 增量编译 * 优化插件 gradle 增量编译
* 2020/05/28
* 调整sdk注入逻辑优化 sdk 注册,避免极端情况下多模块重复注册导致已绑定的实现丢失
### 为什么要使用 ### 为什么要使用
@@ -82,7 +84,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath "com.effective.plugins:component:1.0.6 classpath "com.effective.plugins:component:1.0.8
} }
} }
allprojects { allprojects {

View File

@@ -19,6 +19,8 @@ From the very beginning, I learned that "WeChat's Modular Architecture Reconstru
     * Provide a more user-friendly debug log format      * Provide a more user-friendly debug log format
* 2019/12/09 * 2019/12/09
* Optimization plugin gradle incremental compilation * Optimization plugin gradle incremental compilation
* 2020/05/28
     * Adjust the sdk injection logic, optimize the sdk registration, to avoid the repeated registration of multiple modules in extreme cases, resulting in the loss of the bound implementation
### Why use it ### Why use it
@@ -81,7 +83,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath "com.effective.plugins:component:1.0.6 classpath "com.effective.plugins:component:1.0.8
} }
} }
allprojects { allprojects {

View File

@@ -22,6 +22,7 @@ import com.plugin.pin.home.PHome;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;

View File

@@ -2,7 +2,7 @@ apply from: "./gradleScript/config.gradle"
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.3.50'
ext.component_version = '1.0.6' ext.component_version = '1.0.8'
repositories { repositories {
google() google()

View File

@@ -1,7 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
//apply plugin: 'com.novoda.bintray-release' apply plugin: 'com.novoda.bintray-release'
android { android {
compileSdkVersion 29 compileSdkVersion 29
@@ -29,12 +29,12 @@ dependencies {
} }
//publish { publish {
// userOrg = 'yummylau' userOrg = 'yummylau'
// groupId = 'com.effective.android' groupId = 'com.effective.android'
// artifactId = 'component-core' artifactId = 'component-core'
// publishVersion = '1.0.4' publishVersion = '1.0.5'
// desc = 'Android component core code' desc = 'Android component core code'
// website = 'https://github.com/YummyLau/ComponentPlugin' website = 'https://github.com/YummyLau/ComponentPlugin'
//} }

View File

@@ -2,6 +2,7 @@ package com.plugin.component
import android.app.Application import android.app.Application
import android.util.ArrayMap import android.util.ArrayMap
import android.util.Log
/** /**
* 运行时完成收集 * 运行时完成收集
@@ -40,7 +41,9 @@ class ComponentInfo {
fun registerSdk(sdkClass: Class<*>, sdkImpl: Any) { fun registerSdk(sdkClass: Class<*>, sdkImpl: Any) {
sdkMap[sdkClass] = sdkImpl if(!isSdkReady(sdkClass) || sdkImpl!is Class<*>){
sdkMap[sdkClass] = sdkImpl
}
} }
fun unregisterSdk(sdkKey: Class<*>): Boolean { fun unregisterSdk(sdkKey: Class<*>): Boolean {

View File

@@ -31,6 +31,14 @@ object ComponentManager {
ComponentManager.application = application ComponentManager.application = application
sComponentInfoArrayMap = ArrayMap() sComponentInfoArrayMap = ArrayMap()
sInit = true sInit = true
injectComponentWithSdk(application)
}
/**
* 仅仅用于 asm 注入
*/
private fun injectComponentWithSdk(application: Application){
} }
private fun checkInit() { private fun checkInit() {

View File

@@ -1,10 +1,10 @@
apply plugin: 'groovy' apply plugin: 'groovy'
apply plugin: 'maven' apply plugin: 'maven'
//apply plugin: 'com.novoda.bintray-release' apply plugin: 'com.novoda.bintray-release'
group = 'com.effective.plugins' group = 'com.effective.plugins'
archivesBaseName = 'component' archivesBaseName = 'component'
version = '1.0.6' version = '1.0.8'
//设置本地发布路径 //设置本地发布路径
uploadArchives { uploadArchives {
@@ -20,7 +20,7 @@ dependencies {
implementation gradleApi() implementation gradleApi()
implementation localGroovy() implementation localGroovy()
implementation 'com.android.tools.build:gradle:3.1.0' implementation 'com.android.tools.build:gradle:3.1.0'
implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50' implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.70'
implementation 'org.ow2.asm:asm:7.1' implementation 'org.ow2.asm:asm:7.1'
implementation 'org.ow2.asm:asm-commons:7.1' implementation 'org.ow2.asm:asm-commons:7.1'
implementation 'org.ow2.asm:asm-util:7.1' implementation 'org.ow2.asm:asm-util:7.1'
@@ -43,13 +43,13 @@ repositories {
} }
//publish { publish {
// userOrg = 'yummylau' userOrg = 'yummylau'
// groupId = 'com.effective.plugins' groupId = 'com.effective.plugins'
// artifactId = 'component' artifactId = 'component'
// publishVersion = '1.0.6' publishVersion = '1.0.8'
// desc = 'Android component plugin' desc = 'Android component plugin'
// website = 'https://github.com/YummyLau/ComponentPlugin' website = 'https://github.com/YummyLau/ComponentPlugin'
//} }

0
component-plugin/gradlew vendored Normal file → Executable file
View File

View File

@@ -44,7 +44,7 @@ class Constants {
public static String IMPL_PRE = 'impl-' public static String IMPL_PRE = 'impl-'
public static String COMPONENT_PRE = 'component-' public static String COMPONENT_PRE = 'component-'
public static String DEBUG_COMPONENT_PRE = 'component(Debug)-' public static String DEBUG_COMPONENT_PRE = 'component(Debug)-'
public static String CORE_DEPENDENCY = "com.effective.android:component-core:1.0.4" public static String CORE_DEPENDENCY = "com.effective.android:component-core:1.0.5"
//sourceSet - default //sourceSet - default
public static String JAVA_PATH = "src/main/java" public static String JAVA_PATH = "src/main/java"

View File

@@ -73,7 +73,7 @@ class InjectCodeAdapter extends ClassVisitor {
@Override @Override
protected void onMethodEnter() { protected void onMethodEnter() {
injectComponentAutoInitCode = injectComponentAutoInitCode =
className == sComponentManagerPath && name == "init" && descriptor == "(Landroid/app/Application;)V" className == sComponentManagerPath && name == "injectComponentWithSdk" && descriptor == "(Landroid/app/Application;)V"
} }
@Override @Override

View File

@@ -18,9 +18,9 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true android.enableJetifier=true
systemProp.http.proxyHost=127.0.0.1 #systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8001 #systemProp.http.proxyPort=8001
systemProp.https.proxyHost=127.0.0.1 #systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8001 #systemProp.https.proxyPort=8001

View File

@@ -14,16 +14,16 @@ public class Component implements IComponent {
@Override @Override
public void attachComponent(Application application) { public void attachComponent(Application application) {
Log.d("component-plugin", "Component#attachComponent"); Log.d("component-plugin", "Component#attachComponent");
SdkManager.register(this, ISdk.class, SdkShareImpl.class); // SdkManager.register(this, ISdk.class, SdkShareImpl.class);
SdkManager.register(this, ISdk2.class, SdkShareImpl.class); // SdkManager.register(this, ISdk2.class, SdkShareImpl.class);
SdkManager.register(this, IProvideFromLibrary.class, ProvideFromLibraryImpl.class); // SdkManager.register(this, IProvideFromLibrary.class, ProvideFromLibraryImpl.class);
} }
@Override @Override
public void detachComponent() { public void detachComponent() {
Log.d("component-plugin", "Component#detachComponent"); Log.d("component-plugin", "Component#detachComponent");
SdkManager.unregister(ISdk.class); // SdkManager.unregister(ISdk.class);
SdkManager.unregister(ISdk2.class); // SdkManager.unregister(ISdk2.class);
SdkManager.unregister(IProvideFromLibrary.class); // SdkManager.unregister(IProvideFromLibrary.class);
} }
} }

View File

@@ -2,8 +2,13 @@ package com.plugin.librarykotlin
import android.app.Application import android.app.Application
import android.util.Log import android.util.Log
import com.plugin.component.ComponentManager
import com.plugin.component.IComponent import com.plugin.component.IComponent
import com.plugin.component.SdkManager
import com.plugin.component.SdkManager.getSdk
import com.plugin.component.anno.AutoInjectComponent import com.plugin.component.anno.AutoInjectComponent
import com.plugin.library.IProvideFromLibrary
import com.plugin.library.ISdk
@AutoInjectComponent(impl = [ProvideFromKotlinImpl::class, GetFromLibraryImpl::class]) @AutoInjectComponent(impl = [ProvideFromKotlinImpl::class, GetFromLibraryImpl::class])
@@ -11,6 +16,7 @@ class KotlinComponent : IComponent {
override fun attachComponent(application: Application) { override fun attachComponent(application: Application) {
Log.d("component-plugin", "KotlinComponent#attachComponent") Log.d("component-plugin", "KotlinComponent#attachComponent")
ComponentManager.init(application)
} }
override fun detachComponent() { override fun detachComponent() {

View File

@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Sat Aug 31 17:50:10 CST 2019 #Thu May 28 17:59:06 CST 2020
sdk.dir=/Users/yummy/Library/Android/sdk sdk.dir=/Users/g8931/Library/Android/sdk

View File

@@ -1,6 +1,6 @@
//发布调试 core //发布调试 core
//include ':component-core' //include ':component-core'
//
//发布插件 //发布插件
//include ':component-plugin' //include ':component-plugin'