Use general dependencies on compile but concrete versions on test


I helped with an akka-http plugin, which gives us a new custom directive.
Our deps was only the minimum needed one, sth like this:

    "com.typesafe.akka"  %% "akka-http-core"       % akkaHttpV,
    "com.typesafe.akka"  %% "akka-http"            % akkaHttpV,
    "com.typesafe.akka"  %% "akka-http-spray-json" % akkaHttpV,
   "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV % "test",
   //other test deps

But I needed to check if the directive is fast enought so I created a new test setting, and started to use gatling in it. Gatling have fixed akka version, and bcs my itTests depends on the Tests which depends on the compile, I ended up with two akka-actor versions on my itTest classpath…

If I use the fixed version on my compile too, everything works fine. But I don’t want to force the lib users minimum akka version just bcs I wanted to loadtest my app.

So my question is: How I can compile the code with one akka version, and exclude that version from classpath when I compile and run it tests?

My working solution is:

lazy val ITest = config("it") extend Test

libraryDependencies ++= {
  val akkaHttpV  = "10.0.11"
  val scalaTestV = "3.0.1"
    "com.typesafe.akka" %% "akka-stream" % "2.5.9",
    "com.typesafe.akka" %% "akka-stream-testkit" % "2.5.9"
  ) ++
    "com.typesafe.akka"  %% "akka-http-core"       % akkaHttpV,
    "com.typesafe.akka"  %% "akka-http"            % akkaHttpV,
    "com.typesafe.akka"  %% "akka-http-spray-json" % akkaHttpV,
    "com.typesafe.akka"  %% "akka-http-testkit"    % akkaHttpV  % "test",
    "org.scalatest"      %% "scalatest"            % scalaTestV % "test",
    "com.emarsys"        %  "escher"               % "0.3") ++
    "io.gatling.highcharts" %  "gatling-charts-highcharts" % "2.3.0"          % "it,test",
    "io.gatling"            %  "gatling-test-framework"    % "2.3.0"          % "it,test"


I want to eliminate the first Seq with the akka-streams versions.

Original sbt:

Bonus question: Why I need “it,test” on the gatling deps? My itTests don’t compile with just “it”…