File tree Expand file tree Collapse file tree
buildSrc/src/main/kotlin/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ open class RocketXPlugin : Plugin<Project> {
5252 override fun apply (project : Project ) {
5353 // 应用在 主 project 上,也就是 app module
5454 mRocketXBean = project.extensions.create(" RocketX" , RocketXBean ::class .java)
55- if (! isEnable(project) || hasAndroidPlugin(project)) return
55+ if (! isEnable(project) || hasAndroidPlugin(project) || ! isCurProjectRun(project) ) return
5656 this .appProject = project
5757 // 禁止 release 使用加速插件
5858 if (mFlavorBuildType.toLowerCase().contains(" release" )) return
@@ -126,7 +126,7 @@ open class RocketXPlugin : Plugin<Project> {
126126
127127 appProject.rootProject.allprojects.forEach {
128128 // 剔除 app 和 rootProject
129- if (it.name.equals( " app " ) || it == appProject.rootProject || it.childProjects.size > 0 ) return @forEach
129+ if (hasAppPlugin(it ) || it == appProject.rootProject || it.childProjects.size > 0 ) return @forEach
130130 if (mAllChangedProject?.contains(it.path)?.not () != false ) return @forEach
131131 var mLocalMaven: LocalMaven ? = null
132132 val childProject = it.project
Original file line number Diff line number Diff line change @@ -52,11 +52,25 @@ fun getFlavorBuildType(appProject: Project):String {
5252 flavorBuildType =
5353 flavorBuildType.substring(0 , 1 ).toLowerCase() + flavorBuildType.substring(1 )
5454 }
55-
5655 return flavorBuildType
5756}
5857
5958// 不能通过name ,需要通过 path ,有可能有多级目录(: 作为aar名字会有冲突不能用)
6059fun getFlatAarName (project : Project ): String {
6160 return project.path.substring(1 ).replace(" :" ," -" )
61+ }
62+
63+ fun isCurProjectRun (appProject : Project ):Boolean {
64+ var ret = false
65+ var projectPath = " "
66+ val arg = appProject.gradle.startParameter?.taskRequests?.getOrNull(0 )?.args?.getOrNull(0 )
67+ if (! arg.isNullOrEmpty()) {
68+ var index = arg.indexOf(RocketXPlugin .ASSEMBLE )
69+ index = if (index > 0 ) index - 1 else 0
70+ projectPath = arg.substring(0 ,index)
71+ }
72+ if (projectPath.length > 0 ) {
73+ ret = appProject.path.equals(projectPath)
74+ }
75+ return ret
6276}
You can’t perform that action at this time.
0 commit comments