将现有的gradle依赖项拆分为多个模块

时间:2017-09-24 23:04:49

标签: android maven gradle android-library aar

我目前在maven central上发布了库。该库是android库.aar项目。 问题是当前库需要拆分成多个库,同时保持当前发布的库artifactId以便向后兼容。这是我拥有的一个例子以及我想要实现的目标。

当前artifactId

compile 'com.example:my-library:1.0.0'

新artifactId

compile 'com.example:my-library-core:1.0.0'
compile 'com.example:my-library-deps-1:1.0.0'
compile 'com.example:my-library-deps-2:1.0.0'

compile 'com.example:my-library:1.0.0' (with deps)
--> compile 'com.example:my-library-core:1.0.0'
--> compile 'com.example:my-library-deps-1:1.0.0'
--> compile 'com.example:my-library-deps-2:1.0.0'

所以基本上我的想法是保留原始com.example:my-library maven artifactId,它只对3个新创建的库有依赖关系,以支持旧客户的向后兼容性。

现在我已经尝试在本地创建一个没有工件的pom文件,只有依赖项,但gradle不会因某种原因从依赖项中提取工件。

1 个答案:

答案 0 :(得分:1)

回答我自己的问题。

解决方案是拥有一个没有类和空清单的单独模块,从而导致空.aar存档。这将允许您将现有工件ID与依赖项保持在新模块中。