From 235893c88dc9e2fd69a2261a38def0bd36e3ce56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=B6=85=E7=82=AF?= Date: Fri, 10 Dec 2021 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AD=98=E5=9C=A8=E5=A4=9A=E4=B8=AA=20app?= =?UTF-8?q?lication=20=E5=8F=AA=E6=9C=89run=20=E6=8C=87=E5=AE=9A=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt | 4 ++-- .../src/main/kotlin/plugin/utils/PluginUtil.kt | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) 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