Closed yygutn closed 2 years ago
AGP:4.1.3, Gradle:6.9.1
@yygutn 1、确认一下 根目录/.gradle/.rockect/ 文件夹下面 查看 aar 缓存是否生成 2、开启log ,看下app module 在编译时 真实依赖了都有哪些 dependency(方便的话贴出 log )
RocketX {
openLog = true
}
@trycatchx
第一次无缓存构建:
RocketXPlugin : module name==>:app; countTime=120977685412869
RocketXPlugin : module name==>:xxx; countTime=120855765741363
RocketXPlugin : module name==>:xxx; countTime=93230015559288
RocketXPlugin : module name==>:xxx; countTime=47267792949056
RocketXPlugin : module name==>:xxx; countTime=29509068282074
RocketXPlugin : module name==>:xxx; countTime=115951466596807
RocketXPlugin : module name==>:xxx; countTime=206120250491680
RocketXPlugin : module name==>:xxx; countTime=58726335255833
RocketXPlugin : module name==>:xxx; countTime=128225437637407
RocketXPlugin : count time====>>>> 280
RocketXPlugin : ======project name: app==========
RocketXPlugin : =====Config name:implementation =====
RocketXPlugin : dependency:215916012
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:406621706
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:207109915
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:725216927
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:1995587624
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:308012433
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:1200697010
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':xxx'', configuration='default'}
RocketXPlugin : dependency:849807987
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:-1663809308
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
RocketXPlugin : ======project name: xxx==========
RocketXPlugin : ======project name: ========== end
第二次构建:无任何改动 RocketXPlugin : module name==>:app; countTime=120977685412869 RocketXPlugin : module name==>:xxx; countTime=120855765741363 RocketXPlugin : module name==>:xxx; countTime=93230015559288 RocketXPlugin : module name==>:xxx; countTime=47267792949056 RocketXPlugin : module name==>:xxx; countTime=29509068282074 RocketXPlugin : module name==>:xxx; countTime=115951466596807 RocketXPlugin : module name==>:xxx; countTime=206120250491680 RocketXPlugin : module name==>:xxx; countTime=58726335255833 RocketXPlugin : module name==>:xxx; countTime=128225437637407 RocketXPlugin : hasChangeMap {} RocketXPlugin : count time====>>>> 324 RocketXPlugin : ======project name: app========== RocketXPlugin : =====Config name:implementation ===== RocketXPlugin : dependency:215916012 RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'} RocketXPlugin : dependency:849807987 RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'} RocketXPlugin : dependency:-1663809308 RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'} RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end RocketXPlugin : ======project name: xxx========== RocketXPlugin : ======project name: ========== end
@yygutn 第二次怎么剩下这么点:
RocketXPlugin : ======project name: app==========
RocketXPlugin : =====Config name:implementation =====
RocketXPlugin : dependency:215916012
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:849807987
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:-1663809308
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : ======project name: ========== end
少了的module依赖是哪些?本来是通过 implemntation 依赖进来的吗?
@trycatchx 少了的是 implementation project 依赖进来的业务module
@yygutn 子 module 是否有 使用 flavorImplement/ debugImplement 这样的依赖方式?
@trycatchx 有一个debug模块可能用了debugImplement,不过不太确定,我印象中是debug的build type去Implement的一些测试模块
debugImplement 是支持的。 不过 app module 和 其他的业务 module 的 buildType 需要一致
明天再去瞅瞅怎么写的……build type都是一样的,没有变种
@yygutn 项目在你那边,你可以先自行查看 DependenciesHelper.getFirstLevelParentDependencies 这个方法加入打印,看下 依赖是否有断掉?这个是每一个 module 变成 aar 之后 会把 aar 依赖交到 parent 。最后通过 DependenciesHelper.addAarDependencyToProject 这个方法加入(也可以加入打印)。基本可以看到流程在哪里断的。
@yygutn 你可以帮忙分析一下,找到问题反馈 或者你 提PR 均可
@trycatchx 行,明天看看
@yygutn 顺便确定一下 。 根目录/.gradle/.rockect/ 文件夹下面 你项目所有的 module 对应的 aar (9 个?) 全部生成了没。在 addAarDependencyToProject 这个方法是否执行,并把 aar 依赖添加进去。
上面确定一下,基本就知道原因了。
@trycatchx 加了些日志,addAarDependencyToProject 没有执行,getFirstLevelParentDependencies对应每一个project的configList是空的
getFirstLevelParentDependencies ----- start, project=xxx
getFirstLevelParentDependencies: project:app, add config:configuration ':app:implementation'
getFirstLevelParentDependencies: project:app, configList:[configuration ':app:implementation']
getFirstLevelParentDependencies: project:xxx, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies: project:yyy, configList:null
getFirstLevelParentDependencies ----- end, {project ':app'=[configuration ':app:implementation']}
应该是问题在这里
getAarByArtifacts-----artifacts.size=0
getAarByArtifacts-----listArtifact=[]
getAarByArtifacts-----aarList=[]
modifyDependencies-----artifactAarList=[]
DependenciesHelper#getAarByArtifacts
------ childProject.configurations.maybeCreate("default").artifacts 这个字段是空的
DependenciesHelper#getAarByArtifacts
------ childProject.configurations.maybeCreate("default").artifacts 这个字段是空的
这个没有关系的,这个是指通过特殊的 依赖导进来的的譬如项目build.gradle使用了这种代码:
configurations.maybeCreate("default")
artifacts.add("default", file('lib-xx.aar'))
getFirstLevelParentDependencies 的 log 目前看起来是有问题的,你需要在 ChildProjectDependencies 这个类里面的 init 代码块最后一行加入(目的看下项目所有 module 本身获取的config 依赖 有没有问题) :
LogUtil.d("ChildProjectDependencies project:"+ project)
LogUtil.d("ChildProjectDependencies allConfigList:"+ allConfigList)
@trycatchx
ChildProjectDependencies project:project ':app'
ChildProjectDependencies allConfigList:[configuration ':app:implementation', configuration ':app:api', configuration ':app:compileOnly']
ChildProjectDependencies project:project ':x'
ChildProjectDependencies allConfigList:[configuration ':x:implementation', configuration ':x:api', configuration ':x:compileOnly']
ChildProjectDependencies project:project ':y'
ChildProjectDependencies allConfigList:[configuration ':y:implementation', configuration ':y:api', configuration ':y:compileOnly']
ChildProjectDependencies project:project ':z'
ChildProjectDependencies allConfigList:[configuration ':z:implementation', configuration ':z:api', configuration ':z:compileOnly']
ChildProjectDependencies project:project ':a'
ChildProjectDependencies allConfigList:[configuration ':a:implementation', configuration ':a:api', configuration ':a:compileOnly']
ChildProjectDependencies project:project ':b'
ChildProjectDependencies allConfigList:[configuration ':b:implementation', configuration ':b:api', configuration ':b:compileOnly']
ChildProjectDependencies project:project ':c'
ChildProjectDependencies allConfigList:[configuration ':c:implementation', configuration ':c:api', configuration ':c:compileOnly']
ChildProjectDependencies project:project ':d'
ChildProjectDependencies allConfigList:[configuration ':d:implementation', configuration ':d:api', configuration ':d:compileOnly']
ChildProjectDependencies project:project ':e'
ChildProjectDependencies allConfigList:[configuration ':e:implementation', configuration ':e:api', configuration ':e:compileOnly']
@yygutn 不好意思。好像没有看到依赖,log 需要改一下:
LogUtil.d("ChildProjectDependencies project:" + project)
allConfigList.forEach {
LogUtil.d("ChildProjectDependencies config ==== :" + it)
it.allDependencies.forEach {
LogUtil.d("ChildProjectDependencies dependency:" + it)
}
LogUtil.d("ChildProjectDependencies config end ===" )
}
@trycatchx 其余依赖的project module没有输出 少了2个debug下的依赖
RocketXPlugin : ChildProjectDependencies project:project ':app'
RocketXPlugin : ChildProjectDependencies allConfigList:[configuration ':app:implementation', configuration ':app:api', configuration ':app:compileOnly']
RocketXPlugin : =====ChildProjectDependencies=====Config name:implementation =====
RocketXPlugin : dependency:215916012
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:1021555846
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':a'', configuration='default'}
RocketXPlugin : dependency:1618947996
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':b'', configuration='default'}
RocketXPlugin : dependency:1601133444
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':c'', configuration='default'}
RocketXPlugin : dependency:1222693562
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':d'', configuration='default'}
RocketXPlugin : dependency:1836512183
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':e'', configuration='default'}
RocketXPlugin : dependency:464613922
RocketXPlugin : dependency:DefaultProjectDependency{dependencyProject='project ':f'', configuration='default'}
RocketXPlugin : dependency:849807987
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='xxx', name='xxx', version='xxx', configuration='default'}
RocketXPlugin : dependency:-1663809308
RocketXPlugin : dependency:DefaultExternalModuleDependency{group='cxxx', name='xxx', version='xxx', configuration='default'}
@yygutn 是的 debug 的implement 是遗漏了。所以你编译不过的内容主要是这两个 module 吗?
@yygutn 是的 debug 的implement 是遗漏了。所以你编译不过的内容主要是这两个 module 吗?
那倒不是,只是debug的依赖,没有也不影响
先尝试一下补上去:
//单独的 buildconfig
val buildTypeConfigName = it.buildType + suffix.capitalize()
val buildTypeConfiguration = project.configurations.maybeCreate(buildTypeConfigName)
if (!allConfigList.contains(buildTypeConfiguration)) {
allConfigList.add(buildTypeConfiguration)
}
没用0-0 钉钉or微信沟通一下吧- -有点长
帮忙排查一下红框内的这个条件语句。 理论 module a b c d 的 parent 都是 app ,也就是 获取出来的 MutableList
使用 'io.github.trycatchx:rocketx:1.0.10' 版本解决。
app module依赖了几个业务module,其中一个Activity的ViewModel引用了几个业务module的东西,在存在RocketXPlugin缓存的情况下,build会报错: