diff --git a/buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt b/buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt index 424f7fc..ffd32cf 100644 --- a/buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt +++ b/buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt @@ -52,7 +52,7 @@ open class RocketXPlugin : Plugin { override fun apply(project: Project) { //应用在 主 project 上,也就是 app module mRocketXBean = project.extensions.create("RocketX", RocketXBean::class.java) - if (!isEnable(project) || hasAndroidPlugin(project)) return + if (!isEnable(project) || hasAndroidPlugin(project) || !isCurProjectRun(project)) return this.appProject = project //禁止 release 使用加速插件 if(mFlavorBuildType.toLowerCase().contains("release")) return @@ -126,7 +126,7 @@ open class RocketXPlugin : Plugin { appProject.rootProject.allprojects.forEach { //剔除 app 和 rootProject - if (it.name.equals("app") || it == appProject.rootProject || it.childProjects.size > 0) return@forEach + if (hasAppPlugin(it) || it == appProject.rootProject || it.childProjects.size > 0) return@forEach if (mAllChangedProject?.contains(it.path)?.not() != false) return@forEach var mLocalMaven: LocalMaven? = null val childProject = it.project diff --git a/buildSrc/src/main/kotlin/plugin/utils/PluginUtil.kt b/buildSrc/src/main/kotlin/plugin/utils/PluginUtil.kt index 0a07f1c..8bbf41d 100644 --- a/buildSrc/src/main/kotlin/plugin/utils/PluginUtil.kt +++ b/buildSrc/src/main/kotlin/plugin/utils/PluginUtil.kt @@ -52,11 +52,25 @@ fun getFlavorBuildType(appProject: Project):String { flavorBuildType = flavorBuildType.substring(0, 1).toLowerCase() + flavorBuildType.substring(1) } - return flavorBuildType } //不能通过name ,需要通过 path ,有可能有多级目录(: 作为aar名字会有冲突不能用) fun getFlatAarName(project: Project): String { return project.path.substring(1).replace(":","-") +} + +fun isCurProjectRun(appProject: Project):Boolean { + var ret = false + var projectPath = "" + val arg = appProject.gradle.startParameter?.taskRequests?.getOrNull(0)?.args?.getOrNull(0) + if(!arg.isNullOrEmpty()) { + var index = arg.indexOf(RocketXPlugin.ASSEMBLE) + index = if(index > 0) index - 1 else 0 + projectPath = arg.substring(0,index) + } + if (projectPath.length > 0) { + ret = appProject.path.equals(projectPath) + } + return ret } \ No newline at end of file