如何构建依赖于另一个构建结果的项目?

时间:2016-09-23 11:00:36

标签: java android build.gradle multi-project

我正在组织许多Android Studio项目,构建正在使用gradle。 我目前的计划是:

MainProject:

  • Dependency1 - (图书馆计划)
  • Dependency2 - (图书馆计划)
  • Dependency3 - (图书馆计划)
  • Dependency4 - (图书馆计划)

settings.gradle

include ':SDK:Dependency1'
include ':SDK:Dependency2'
include ':SDK:Dependency3'
include ':SDK:Dependency4'

include "MainProject"
project(":MainProject").setProjectDir(new File("./ProjectName"))

MainProject /的build.gradle

debugCompile project(path: ':SDK:Dependency1', configuration: 'debug')
releaseCompile project(path: ':SDK:Dependency1', configuration: 'release')
debugCompile project(path: ':SDK:Dependency2', configuration: 'debug')
releaseCompile project(path: ':SDK:Dependency2', configuration: 'release')
debugCompile project(path: ':SDK:Dependency3', configuration: 'debug')
releaseCompile project(path: ':SDK:Dependency3', configuration: 'release')
debugCompile project(path: ':SDK:Dependency4', configuration: 'debug')
releaseCompile project(path: ':SDK:Dependency4', configuration: 'release')

我想将其称为aar库,因此我的MainProject / build.gradle正在变为。

   compile "com.dependency.sdk.Dependency1:$SDKVersion"
   compile "com.dependency.sdk:Dependency2:$SDKVersion"
   compile "com.dependency.sdk:Dependency3:$SDKVersion"
   compile "com.dependency.sdk:Dependency4:$SDKVersion"

问题是:当我这样做时,构建在配置阶段失败,因为MainProject无法解析依赖关系,因为依赖库尚未构建。

如何在不修改settings.gradle文件的情况下解决这个问题?(我想只有一个settings.gradle文件)。

0 个答案:

没有答案