# Kotlin Dependencies in Gradle Projects

**URL:** <https://discuss.kotlinlang.org/t/kotlin-dependencies-in-gradle-projects/10490>\
**Category:** Libraries\
**Created:** [November 23, 2018, 2:35pm UTC](https://discuss.kotlinlang.org/t/kotlin-dependencies-in-gradle-projects/10490 "2018-11-23T14:35:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dlee](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dlee](https://discuss.kotlinlang.org/u/dlee)\
**Post date:** [November 30, 2018, 2:31am UTC](https://discuss.kotlinlang.org/t/kotlin-dependencies-in-gradle-projects/10490/4 "2018-11-30T02:31:05Z")

</div>

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.

---

_[View the full topic](https://discuss.kotlinlang.org/t/kotlin-dependencies-in-gradle-projects/10490)._
