mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.11k stars 202 forks source link

MockitoCore version includes bytebuddy that is not supported for Jetifier #312

Closed danielgomezrico closed 5 years ago

danielgomezrico commented 5 years ago

Is there any specific reason to use mockito core 2.23.0 ?

The thing is that it contains a dependency to bytebuddy v 1.9 and that breaks Jetifier, in my case with:

Check: https://github.com/raphw/byte-buddy/issues/541#issuecomment-429649501

Warning: Exception while processing task java.io.IOException: Can't write [/myapp/android/app/build/intermediates/transforms/proguard/androidTest/debug/0.jar] (Can't read [/Users/danielgomez22/.gradle/caches/transforms-1/files-1.1/byte-buddy-agent-1.9.0.jar/ae6d09949b3f418f0c110b790fdd5881/jetified-byte-buddy-agent-1.9.0.jar(;;;;;;;**.class)] (Duplicate jar entry [module-info.class]))

Is there any way for you to force the bytebuddy dependency to be 1.8.22 instead of 1.9 or change to a mockitocore version that use it?

matejdro commented 5 years ago

You can add this to your gradle.build:

configurations.all {
    resolutionStrategy {
        force 'net.bytebuddy:byte-buddy:1.8.22'
        force 'net.bytebuddy:byte-buddy-agent:1.8.22'
    }
}
danielgomezrico commented 5 years ago

@matejdro thanks! I already did that. I was just worried about other people using the library and getting the same issues, so I asked why do you use that specific version or we can have one that does not break things with jetiffier.

matejdro commented 5 years ago

I'm not sure they need a reason to use latest version of the library. It's Jetifier that needs to get fixed to support new version.

nhaarman commented 5 years ago

Mockito 2.23.0 is necessary to support coroutines, see #299 and the linked issues. You can apply https://github.com/nhaarman/mockito-kotlin/issues/312#issuecomment-447761074, but what you'd really want to do is push for Byte Buddy or Jetifier to fix the issue.

danielgomezrico commented 5 years ago

Makes total sense, thanks for answering.