jeudi 5 février 2015

Gradle Android, exclude dependency from another module

I have an Android app, who I want to unit test. With the MVP pattern, I was able to extract a lot of classes outside of the "android world" in order to test them as plain unit tests (with Junit) inside a separate module[1]. However, I would like to log some messages from those classes. So I have tried to use slf4j-api with the android binding. With the intention to provide the simple binding on my tests. But the "test" module start with complaining that there are two slf4j binding in the classpath and that he is using the android-binding.


So my question is, How can I exclude the slf4j-android dependency from the "test" module ? Here is the build.gradle of my "test" module



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://ift.tt/1rphoZm


Aucun commentaire:

Enregistrer un commentaire