SBT dependencyOverrides in a scope doesn't seem to work as expected

Viewed 204

I would like to have a different version of library in test scope.

I was hoping the simplified version of project descriptor could look like that. Please mind it's a simplified view, in my real project it's more convoluted. I need to use dependencyOverrides to enforce certain library version.

import sbt._, Keys._

organization :=  "me"
name := "test"
version := "0.1"

libraryDependencies := Seq("ch.qos.logback" % "logback-classic" % "1.2.3")

dependencyOverrides := Seq(
  "ch.qos.logback" % "logback-classic" % "1.2.2"
)

dependencyOverrides in Test := Seq(
  "ch.qos.logback" % "logback-classic" % "1.2.1"
)

I'd be hoping to see logback-classic version 1.2.1 when I run: show test:managedClasspath. Instead I get logback-classic version 1.2.2 as if dependencyOverrides in Test was ignored.

At the same time when I run show Test/dependencyOverrides I get the expected result which is:

ch.qos.logback:logback-classic:1.2.1

Does anyone has a clue what am I missing in the relation between dependencyOverrides in Test scope and managedClasspath?

1 Answers

It appears the problem cannot be solve the way I imagined. The main reason is libraryDependencies and update are not scoped to configuration.

I think the best solution is in case I need a different version of library in some tests to extract those tests to a separate module with independent set of libraryDependencies.

Related