Open bvschaik opened 11 months ago
Does this mean we are stuck with v4.x for Android development for the foreseeable future?
The drop of compatibility is listed on mockito-core in its release notes combined with the rationale: https://github.com/mockito/mockito/releases/tag/v5.0.0
If you still need to support Java 8, you can keep on using Mockito 4. Nothing should break there.
I was unaware that Mockito 5 no longer offers support for Java 8. Does this imply that for Android projects, the jvmTarget should now be set to VERSION_11? It seems to be supported with Android Gradle Plugin 7.0. https://developer.android.com/build/releases/past-releases/agp-7-0-0-release-notes#java-11
If that's the case, would it be advisable to include a note in the Readme.md specifically for Android developers regarding this change?
Yes that is indeed now required. Feel free to send me a PR with a README update on the version similar to what we have in the README of mockito-core
.
i have set jvmtarget and compatibility in compileoptions to Java 11 but the problem still exists
@wiryadev, would it be possible for you to share an example project that demonstrates the issue you're encountering?
The project linked at the beginning of this issue, https://github.com/bvschaik/mockito-kotlin-error, was resolved by adjusting the compile options to use JVM 11.
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
@wiryadev, would it be possible for you to share an example project that demonstrates the issue you're encountering?
The project linked at the beginning of this issue, https://github.com/bvschaik/mockito-kotlin-error, was resolved by adjusting the compile options to use JVM 11.
compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = '11' }
unfortunately it is not possible currently to create sample project for that nor that it is possible to share my office work project. I choose to just downgrade to 4.1.0. My current assumption is this happens because of some dependency that i use is compiled against Java 8.
Android projects still use JVM target 1.8 due to device constraints; the gradle file therefore contains:
Upgrading mockito-kotlin from 4.1.0 to 5.0.0 causes the following compile error on any mock/whenever/etc call:
JVM target 11 is nowhere to be found in the Gradle files.
Steps to reproduce:
./gradlew testDebugUnitTest
If you downgrade mockito-kotlin to 4.1.0, the project compiles and runs successfully.
If mockito-kotlin no longer supports JVM 1.8, that should've been noted in the changelog.