Code Monkey home page Code Monkey logo

spi's Introduction

spi

中文

SPI for componentization.

Download

Add spi-gradle-plugin to your project !


buildscript {
   ext {
        kotlin_version = '1.5.31'
        booster_version = '4.6.0'
   }

  repositories {
    mavenCentral()
    google()
    // jcenter()
    
    // didi booster
    maven { url 'https://oss.sonatype.org/content/repositories/public/' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    
    // add maven repository for spi-plugin at build.gradle file of root project
    maven { url "https://raw.githubusercontent.com/afirez/apps_android_repo/master" }
    // maven { url "https://raw.githubusercontent.com/afirez/spi/master/repo/" }
  }

  dependencies {
    classpath 'com.afirez.spi:spi-gradle-plugin:3.0.0'
    // ①
    classpath "com.didiglobal.booster:booster-gradle-plugin:$booster_version"
    // ② figure out the features you really need, then choose the right module for integration
    // ② 弄清楚真正需要的特性,然后从下面的模块列表中选择正确的模块进行集成
    // classpath "com.didiglobal.booster:booster-task-all:$booster_version"
    // classpath "com.didiglobal.booster:booster-transform-all:$booster_version"
        
    // gradle plugin version <= 4.1.2
    // classpath 'com.afirez.spi:spi-gradle-plugin:2.0.0'
    
    // gradle plugin version <= 3.6.4
    // classpath 'com.afirez.spi:spi-gradle-plugin:1.0.1'
  }
}

// in module build.gradle
apply plugin: 'com.android.application'

// didi booster
apply plugin: 'com.didiglobal.booster' // ③

// gradle plugin version <= 4.1.2
// apply plugin: 'spi' 
// or apply plugin: 'com.afirez.spi'

Add spi to module project if needed !

allprojects {
  repositories {
    ...
    
    mavenCentral()
    google()
    // jcenter()
    
    // didi booster
    maven { url 'https://oss.sonatype.org/content/repositories/public/' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }

    // add maven repository for spi at build.gradle file of root project
    maven { url "https://raw.githubusercontent.com/afirez/apps_android_repo/master" }

    ...
  }
}

implementation "com.afirez.spi:spi:1.0.1" 

Usage

SPI AppLike

Make every module aware of Application lifecycle by annotated with @SPI, it will be discovered an registered to ExtensionLoader. eg:

Then, AppDelegate will load and dispatch AppLikes by ExtensionLoader.

Call AppDelegate in App and don't forget to register App to AndoridManifest.xml. Enjoy it!

SPI Actiivty

Annotate Activity with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path. (if it annotated without path, path will be it's class name.)

SPI Fragment

Annotate Fragment with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path. (if it annotated without path, path will be it's class name.)

SPI Provider

Annotate SpiKotlinProviderImpl with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path.(if it annotated without path, path will be it's class name.)

Do more by SPI

SPI focuses on interface discovery, registration and routing table implementation. So We can collect and dispath interface like AppLike, or make a router implementation based on SPI, and etc.

Thanks

License

Copyright 2019 afirez

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

spi's People

Contributors

afirez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spi's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.