Skip to content

Commit f634f7c

Browse files
committed
update README
1 parent da0757e commit f634f7c

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

README.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
- [x] v2 版已经支持 `AGP 7.4+` | ~~(v1 老版本是基于 `AGP4``Transform` 接口)~~
1414
- [x] 支持过滤和增量,并优化 `Transform` 流程,合理配置过滤时能极大幅度缩减编译时间。
15+
- [x] 支持根据 `variant` 进行不同的配置和处理。
1516
- [x] 插件内部多线程并行 IO 处理,提升编译速度。
1617
- [x] 基于 `asm-tree` 实现的接口更加易于修改字节码。
1718
- [x] 插件平台化,支持挂载多个字节码修改器,且使用多个修改器也只会有一次 IO 产生。
@@ -56,46 +57,53 @@
5657

5758
#### 使用
5859

59-
1. 项目已经发到 `jitpack.io` 仓库,依赖如下
60+
1. 项目已经发到 `jitpack.io` 仓库,在项目根 `build.gradle.kts` 中配置如下
6061

61-
```groovy
62+
```kotlin
6263
// Top-level build file
6364
buildscript {
6465
repositories {
65-
maven { url 'https://jitpack.io' }
66+
maven { setUrl("https://jitpack.io") }
6667
}
68+
6769
dependencies {
68-
classpath "com.github.Ysj001.BytecodeUtil:plugin:<lastest-version>"
70+
// BCU 插件依赖
71+
classpath("com.github.Ysj001.BytecodeUtil:plugin:<lastest-version>")
6972
}
7073
}
7174

7275
subprojects {
7376
repositories {
7477
maven { url 'https://jitpack.io' }
75-
... ...
7678
}
7779
}
7880
```
7981

80-
2.`android application` 模块中使用并配置插件
82+
2.`app` 模块的 `build.gradle.kts` 中的配置如下
8183

82-
```groovy
83-
apply plugin: 'com.android.application'
84-
// 使用 bcu 插件
85-
apply plugin: 'bcu-plugin'
84+
```kotlin
85+
plugins {
86+
id("com.android.application")
87+
id("org.jetbrains.kotlin.android")
88+
// 添加 bcu 插件
89+
id("bcu-plugin")
90+
}
8691

8792
// 插件扩展
88-
bytecodeUtil {
89-
// 设置插件日志级别 (0 ~ 5)
90-
loggerLevel = 1
91-
// 挂载你所需的修改器,可以挂载多个,插件内部按顺序执行
92-
modifiers = [
93-
// 你要挂载的修改器的 class
94-
Class.forName("xxxxx")
95-
]
96-
// 不需要处理的 class 文件过滤器,合理配置可提大幅升编译速度。
97-
notNeed = { entryName ->
93+
bcu {
94+
config { variant ->
95+
// 设置插件日志级别 (0 ~ 5)
96+
loggerLevel = 2
97+
// 挂载你所需的修改器,可以挂载多个,插件内部按顺序执行
98+
modifiers = arrayOf(
99+
// 将 CustomModifier 添加到 bcu 中
100+
CustomModifier::class.java,
101+
)
102+
}
103+
// 不需要处理的 class 文件过滤器。
104+
filterNot { variant, entryName ->
98105
// 这里传 false 表示不过滤
106+
// 请按需配置过滤,合理配置可提大幅升编译速度
99107
false
100108
}
101109
}
@@ -206,6 +214,7 @@ log 对应的具体含义:
206214
| log key | 对应含义 |
207215
| ------------------------------- | ------------------------------------------- |
208216
| >>> loggerLevel | 当前 BCU 的日志等级(0~5) |
217+
| >>> variant | 当前变体名称 |
209218
| >>> apply modifier | 添加进 BCU 的 Modifier |
210219
| >>> xxxModifier initialize time | xxxModifier 在 initialize 阶段的耗时 |
211220
| >>> bcu scan time | BCU 在 scan 阶段的总耗时 |

0 commit comments

Comments
 (0)