How do I lock dependencies in gradle 6.7.1?

Viewed 4331

I was reading the documentation for dependency locking in gradle. I put the following incantation in my deps.gradle file and versions are still sliding around.

dependencyLocking {
  lockAllConfigurations()
}

I then noticed the caveat "The above will lock all project configurations, but not the buildscript ones" but I could not find docs that explained the difference.

What is the difference and how can I lock all dependencies?

Note that I'm aware of one other way of locking depenencies that does seem to work, but it seems very verbose so I'd like to avoid it if possible:

  implementation('com.github.jnr:jffi') {
    version {
       strictly '1.2.23'
    }
  }
1 Answers
lockAllConfigurations()

only makes all of you configurations eligible for dependency locking. It does not automatically lock the dependencies. Otherwise the dynamic version will become useless and you can simply specify the exact version number when adding dependencies.

To actually produce the dependency lock file, you need to pass --write-locks to gradle when running a task, e.g.:

gradle dependencies --write-locks

See this part of the documentation.

Related