Skip to content

Commit d146bea

Browse files
authored
Merge pull request #8 from daishengda2018/master
修复 moduleProject 空指针
2 parents c8908e7 + c78dd91 commit d146bea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/kotlin/org/lizhi/tiya/dependency/DependencyReplaceHelper.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class DependencyReplaceHelper(private val pluginContext: IPluginContext) {
116116
// 获取所有的模块工程集合
117117
val moduleProjectList = pluginContext.getModuleProjectList()
118118

119-
// 从集合中查找到需要替换依赖的module工程, 如果currentProject==app工程, 这里查询结果是null
119+
// 从集合中查找到需要替换依赖的module工程, 如果 currentProject == app 工程, 这里查询结果是null
120120
val moduleProject = moduleProjectList.firstOrNull { it.moduleExtension.name == currentProject.path }
121121

122122
// 替换所有待处理的module工程依赖
@@ -129,7 +129,8 @@ class DependencyReplaceHelper(private val pluginContext: IPluginContext) {
129129
handleReplaceDependency(configuration, dependency, currentProject)
130130
}
131131
}
132-
// 把下层的依赖投递到上层, 由于下层的module变成aar后会丢失它所引入的依赖,因此需要将这些依赖回传给上层
132+
133+
// 把下层的依赖投递到上层, 由于下层的 module 变成 aar 后会丢失它所引入的依赖,因此需要将这些依赖回传给上层
133134
if (parent == pluginContext.getApplyProject() || (parent != null && moduleProject != null && moduleProject.cacheValid)) {
134135
// 原始类型
135136
DependencyUtils.copyDependencyWithPrefix(currentProject, parent, "")
@@ -138,8 +139,8 @@ class DependencyReplaceHelper(private val pluginContext: IPluginContext) {
138139
// release前缀类型
139140
DependencyUtils.copyDependencyWithPrefix(currentProject, parent, "release")
140141
// 变体前缀
141-
val flavorName = moduleProject!!.moduleExtension.flavorName
142-
if (flavorName.isNotBlank()) {
142+
val flavorName = moduleProject?.moduleExtension?.flavorName
143+
if (flavorName != null && flavorName.isNotBlank() && flavorName.isNotEmpty()) {
143144
//api debugApi tiyaDebugApi
144145
DependencyUtils.copyDependencyWithPrefix(currentProject, parent, flavorName)
145146
DependencyUtils.copyDependencyWithPrefix(currentProject, parent, flavorName + "Debug")

0 commit comments

Comments
 (0)