简体   繁体   中英

How to upgrade the version of a transitive dependency in SBT?

In my SBT configuration, is there a way that I can force a dependency to upgrade to the latest version of a transitive dependency? eg I have

"org.springframework.data" % "spring-data-neo4j" % "4.0.0.RELEASE"

as a dependency which I have declared in a plugin and use across many projects. It internally uses

"org.neo4j" % "neo4j-ogm" % "1.1.2"

as a transitive dependency.

I want to upgrade to

"org.neo4j" % "neo4j-ogm" % "1.1.4"

Is there a way to achieve this without switching to manual mode of doing all dependency management?

If you add the transitive dependency as an explicit dependency with the newer version, then SBT / Ivy will resolve the conflict between the two by choosing the newer version:

libraryDependencies ++= Seq(
  "org.springframework.data" % "spring-data-neo4j" % "4.0.0.RELEASE",
  "org.neo4j" % "neo4j-ogm" % "1.1.4"
)

After running sbt compile , you can look at the Ivy dependency report in target/resolution-cache/reports/<my-project>-compile.xml (open it in a web browser) for a full summary of which dependencies were chosen by Ivy and how all conflicts were resolved.

Specify the version "org.neo4j" % "neo4j-ogm" % "1.1.4" in libraryDependencies. The version specified will override (evict).

  +-org.springframework.data:spring-data-neo4j:4.0.0.RELEASE
     +-org.neo4j:neo4j-ogm:1.1.2 (evicted by: 1.1.4)
     +-org.neo4j:neo4j-ogm:1.1.4
     | +-ch.qos.logback:logback-classic:1.1.3
     | | +-ch.qos.logback:logback-core:1.1.3
     | | +-org.slf4j:slf4j-api:1.7.12

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM