[英]Gradle Android, exclude dependency from another module
我有一个Android应用程序,我想进行单元测试。 使用MVP模式,我能够在“android世界”之外提取很多类,以便在单独的模块[1]中将它们作为普通单元测试(使用Junit)进行测试。 但是,我想从这些类中记录一些消息。 所以我试图将slf4j-api
与android绑定一起使用。 有意在我的测试中提供简单的绑定。 但是“ 测试 ”模块开始抱怨类路径中有两个slf4j绑定,并且他正在使用android-binding。
所以我的问题是,如何从“ 测试 ”模块中排除slf4j-android
依赖? 这是我的“ 测试 ”模块的build.gradle
evaluationDependsOn(":app")
apply plugin: 'java'
dependencies {
def app = project(':app')
testCompile project(path: ':app', configuration: 'debugCompile')
def debugVariant = app.android.applicationVariants.find({it.name == 'debug'})
testCompile debugVariant.javaCompile.classpath
testCompile debugVariant.javaCompile.outputs.files
testCompile files(app.plugins.findPlugin("com.android.application").getBootClasspath())
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile 'org.assertj:assertj-core:1.7.1'
}
[1] http://blog.blundell-apps.com/how-to-run-robolectric-junit-tests-in-android-studio/
使用“exclude”属性删除依赖库。 类似于以下内容:
testCompile'junit:junit:4.12'{exclude'slf4j-android'}
我不确定您需要从哪个库中排除它。 要找到答案,请使用gradle列出库依赖项。
gradle依赖
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.