-
Notifications
You must be signed in to change notification settings - Fork 0
Home
EVIL MOUTH edited this page Oct 22, 2021
·
4 revisions
Welcome to the Startup wiki!
// in root/build.gradle
buildscript {
ext {
startup_version = <latest_version>
}
repositories {
mavenCentral()
}
dependencies {
classpath "net.evilmouth.startup-core-plugin:$startup_version"
}
}
allprojects {
repositories {
mavenCentral()
}
}
// in each module/build.gradle
dependencies {
implementation "net.evilmouth.startup-core:$startup_version"
}
// in app/build.gradle
apply plugin: 'bytex'
apply plugin: 'com.zyhang.startup'
// optional
StartupExtension {
excludeTaskList = [
'com/zyhang/startup/app/M'
]
}
- 实现一个 StartupTask,并使用 @StartupTaskRegister 声明
- 在 Application 启动 StartupCore
// create new class
@StartupTaskRegister(id = "a.A")
class A : AndroidStartupTask() {
override fun startup(context: Context) {
Log.i("Core", "A startup")
}
}
// in Application
StartupCoreAndroid(this)
.startup()
annotation class StartupTaskRegister(
/**
* 任务id,唯一标识
*/
val id: String,
/**
* 该任务所依赖的任务id集合,一个模块可能需要依赖多个模块
*/
val idDependencies: Array<String> = [],
/**
* 任务执行器,默认为BlockExecutor,即直接在当前线程(App启动线程)执行
* @see BlockExecutor 同步 串行
* @see IOExecutor 异步 并行
* @see CPUExecutor 异步 并行
*/
val executorFactory: KClass<out ExecutorFactory> = BlockExecutor.Factory::class,
/**
* 当 executor 不是 BlockExecutor(理解为异步)时,是否需要阻塞当前线程(App启动线程)
* 当然如果使用 BlockExecutor,该属性不管 true/false 作用都一样
*/
val blockWhenAsync: Boolean = false,
/**
* 进程名,默认空表示在主进程
* 不允许两个不同进程的任务之间有依赖关系的
*/
val process: String = "",
/**
* 优先级越大,任务越快分发
* 如果两个同度任务优先级一致,该框架不能保证分发顺序
*/
val priority: Int = 0,
)
- excludeTaskList 需要排除的启动任务
例子
StartupExtension {
excludeTaskList = [
'com/zyhang/startup/app/M'
]
}