So i am running into issues upgrading from kotlin ...
# android
t
So i am running into issues upgrading from kotlin 1.4.32 to 1.5 due to all of our pure kotlin libraries using junit5, some of those libraries provide test-fixtures for downstream tests which then expose helpers built up on both junit4 and junit5. Plus the android unit tests are still on junit4. My initial thought was just update the android unit test configuration to use junit5 with the legacy runner, but some of those test fixtures are also going to have issues on the androidTest configs, which junit 5 in that setting becomes much less real of an option. anyone else ran into something like this?
Copy code
Cause 1: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.5.0.
Required by:
    project :app
Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit' has been rejected:
   Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.5.0(junit5Api)]
...
Cause 2: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.5.0.
Required by:
    project :app > project :appStartup
    project :app > project :flow-ext
    project :app > project :json-ext
    project :app > project :retrofit-ext
    project :app > project :session-data
Caused by: org.gradle.api.GradleException: Module 'org.jetbrains.kotlin:kotlin-test-junit5' has been rejected:
   Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.5.0' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.5.0(junitApi)]
solution
Copy code
configurations.all {
        resolutionStrategy.capabilitiesResolution
            .withCapability("org.jetbrains.kotlin:kotlin-test-framework-impl:$kotlinVersion") {
                val junit4 = candidates.find { (it.id as? ModuleComponentIdentifier)?.module == "kotlin-test-junit" }
                val junit5 = candidates.find { (it.id as? ModuleComponentIdentifier)?.module == "kotlin-test-junit5" }
                if(useJunit5) junit5?.let { select(it) }
                else junit4?.let { select(it) }
            }
    }