[英]Gradle: How to have a 'mock' buildType depend on a 'mock' buildType of another android library project?
I have two gradle modules 我有两个gradle模块
:app
(android application) :app
(Android应用程序) :data
(android library) :data
(Android库) :app
depends on :data
. :app
取决于:data
。 I created an additional buildType
for both modules called mock
. 我创建了一个额外的
buildType
两个模块叫做mock
。 When I build :app
in the mock
buildType
, I want :data
to be automatically built in the mock
buildType
. 当我在
mock
buildType
构建:app
时,我希望:data
在mock
buildType
自动构建。 How can I achieve this? 我该如何实现?
I tried with something like the following in :app
's build.gradle
: 我在
:app
的build.gradle
尝试了以下build.gradle
:
mockCompile project(path: ':data', configuration: 'mock')
But this error is thrown: Error: Configuration with name 'mock' not found.
但是会引发此错误:
Error: Configuration with name 'mock' not found.
:data
has the following buildTypes
: :data
具有以下buildTypes
:
android {
buildTypes {
debug {
shrinkResources true
}
mock {
initWith(buildTypes.debug)
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Add the line below to the build.gradle of you data module 将以下行添加到数据模块的build.gradle中
publishNonDefault true
By default, android just publish the release build of your library, So the app module can not see the mock build of you data library. 默认情况下,Android只是发布您的库的发行版,因此app模块无法看到您的数据库的模拟版。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.