Skip to content

Commit

Permalink
🐛 对 lib_single 单独构建时未设置应用名字而构建失败
Browse files Browse the repository at this point in the history
  • Loading branch information
985892345 committed Feb 15, 2024
1 parent 1a8a4bc commit e66a7b0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build-logic/core/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ gradlePlugin {
id = "lib"
}

create("lib.single") {
implementationClass = "LibSinglePlugin"
id = "lib.single"
}

create("lib.utils") {
implementationClass = "LibUtilsPlugin"
id = "lib.utils"
Expand Down
24 changes: 24 additions & 0 deletions build-logic/core/library/src/main/kotlin/LibSinglePlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.gradle.kotlin.dsl.apply

/**
* .
*
* @author 985892345
* @date 2024/2/15 16:37
*/
class LibSinglePlugin : BasePlugin() {
override fun PluginScope.configure() {
apply(plugin = "base.library")
if (project.gradle.startParameter.taskNames.any { it.contains(":lib_single:assembleDebug") }) {
// 在 AS 使用锤子对 lib_single 模块单独进行构建时,
// 会因为 AndroidManifest 文件没有设置 single_module_app_name 会构建失败,
// 所以这里就设置一个默认的名字
// 单模块的名字在另一个地方设置的
androidLib {
defaultConfig {
manifestPlaceholders["single_module_app_name"] = project.name
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ModuleManagerPlugin : BasePlugin() {
projectName == "lib_utils" -> "lib.utils"
projectName == "lib_config" -> "lib.config"
projectName == "lib_debug" -> "lib.debug"
projectName == "lib_single" -> "lib.single"
projectName.startsWith("module_") -> "module"
projectName.startsWith("lib_") -> "lib"
projectName.startsWith("api_") -> "api"
Expand Down

0 comments on commit e66a7b0

Please sign in to comment.