Enforcing dependency version

I am using gradle version 4.X in my project. I want to force a transitive jar to a particular version. I followed https://docs.gradle.org/4.9/userguide/managing_transitive_dependencies.html#sec:enforcing_dependency_version. But the problem here is that the jar version I want to force lies deep.


Sun (parent jar)

  • Earth
    • Countries
      • India-1.0 --------> (want to force it to version 2.0)
  • Mercury
  • Mars

How can this be achieved in gradle?