Kotlin Dependencies in Gradle Projects

Ive been having the same problem, took me several days to fix 5 builds.
Some causes of getting old kotlin libs came from public libs that have not been updated, like jackson-kotlin-module which was referencing kotlin 1.2

Whats working for me right now is a combination of heavy hammers, also used to solve some related but different issues with gradle 5.0 updates.

  • First remove all references to all kotlin libraries except the jvm – add them back only if needed.
  • Delete all caches of everything everywhere
  • move dependencies from custom configurations to configuration extensions.

I.e change:

configuration {
   custom
}

dependencies {
    custom  "module:vers"
...
}

a child project …

    dependencies {
        compile  configurations.custom   // used to work
    }

to

child project

configurations  {
   implementation.extendsFrom custom
}

Force kotlin version alignment
root project

ext {
  kotlinVersion = "1.3.10"
}
plugins {
  id "org.jetbrains.kotlin.jvm" version "1.3.10"
}
allprojects {
  apply plugin: 'java'
  configurations.forEach { config ->
    config.resolutionStrategy.eachDependency { DependencyResolveDetails details ->
      if (details.requested.group == "org.jetbrains.kotlin"
          && details.requested.name.startsWith("kotlin-")) {
        println("forcing $details to $kotlinVersion")
        details.useVersion kotlinVersion
      }
    }
  }

Then for extra points I had to do this due to various libraries pulling in different jackson modules
The same trick should work for kotlin library transitive dependencies
// HACK

  configurations.all {
    resolutionStrategy {
      preferProjectModules()
      force 'com.fasterxml.jackson.core:jackson-core:2.9.7',
          'com.fasterxml.jackson.core:jackson-databind:2.9.7'
      dependencySubstitution {
        substitute module('com.fasterxml.jackson.core:jackson-core:2.6.6') with module('com.fasterxml.jackson.core:jacks
on-core:2.9.7')
        substitute module('com.fasterxml.jackson.core:jackson-databind:2.6.6') with module('com.fasterxml.jackson.core:j
ackson-databind:2.9.7')
        substitute module('com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.6.6') with module('com.fasterxml.j
ackson.dataformat:jackson-dataformat-cbor:2.9.7')
      }
    }
  }

I dont fully understand the difference between the last 2, i.e. is there a difference between substituting a module with ‘substitute’ vs changing the resolution details object ? don’t know – worked – eventually.