question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change in classpath ordering compared to Ivy

See original GitHub issue

I have a little sbt project reproducer that upgrading from sbt 1.2.8 to sbt 1.3.5 (and, therefore, to Coursier) changes the order of the dependencies, which in turn breaks the project.

build.sbt

scalaVersion in ThisBuild := "2.13.1"

libraryDependencies += "com.typesafe.play" %% "play-test" % "2.8.0-RC1" % Test
libraryDependencies += "org.scalatest"     %% "scalatest" % "3.0.8"     % Test

src/test/scala/t/UnitSpec.scala

import com.typesafe.config.ConfigFactory
import org.scalatest.{ MustMatchers, WordSpec }

class UnitSpec extends WordSpec with MustMatchers {
  def conf = ConfigFactory.defaultReference()

  "Config" should {
    "return Akka HTTP server provider" in {
      val serverProvider = conf.getString("play.server.provider")
      serverProvider mustBe "play.core.server.AkkaHttpServerProvider"
    }

    "be able to load Netty settings" in {
      val nettyTransport = conf.getString("play.server.netty.transport")
      nettyTransport mustBe "jdk"
    }
  }
}

Using sbt 1.2.8, all works as expected:

17:36:22 $ sbtx -Dsbt.version=1.2.8 test
[warn] sbt version mismatch, current: 1.2.8, in build.properties: "1.3.5", use 'reboot' to use the new value.
[info] Loading settings for project global-plugins from global-plugins.sbt ...
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/1.0/plugins
[info] Loading project definition from /s/t-sbt-cp-order/project
[info] Loading settings for project t-sbt-cp-order from build.sbt ...
[info] Set current project to t-sbt-cp-order (in build file:/s/t-sbt-cp-order/)
[info] UnitSpec:
[info] Config
[info] - should return Akka HTTP server provider
[info] - should be able to load Netty settings
[info] ScalaTest
[info] Run completed in 483 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2
[success] Total time: 2 s, completed 17-Dec-2019 17:36:33

Using sbt 1.3.5, it fails:

17:37:11 $ sbtx -Dsbt.version=1.3.5 test
[info] Loading settings for project global-plugins from global-plugins.sbt ...
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/1.0/plugins
[info] Loading project definition from /s/t-sbt-cp-order/project
[info] Loading settings for project t-sbt-cp-order from build.sbt ...
[info] Set current project to t-sbt-cp-order (in build file:/s/t-sbt-cp-order/)
[info] UnitSpec:
[info] Config
[info] - should return Akka HTTP server provider *** FAILED ***
[info]   "play.core.server.[Netty]ServerProvider" was not equal to "play.core.server.[AkkaHttp]ServerProvider" (UnitSpec.scala:12)
[info] - should be able to load Netty settings
[info] ScalaTest
[info] Run completed in 480 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed: Total 2, Failed 1, Errors 0, Passed 1
[error] Failed tests:
[error] 	UnitSpec
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 2 s, completed 17-Dec-2019 17:37:21

Using sbt 1.3.5 without Coursier succeeds again:

17:37:46 $ sbtx -Dsbt.version=1.3.5 -Dsbt.coursier=false test
[info] Loading settings for project global-plugins from global-plugins.sbt ...
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/1.0/plugins
[info] Loading project definition from /s/t-sbt-cp-order/project
[info] Loading settings for project t-sbt-cp-order from build.sbt ...
[info] Set current project to t-sbt-cp-order (in build file:/s/t-sbt-cp-order/)
[info] UnitSpec:
[info] Config
[info] - should return Akka HTTP server provider
[info] - should be able to load Netty settings
[info] ScalaTest
[info] Run completed in 441 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2
[success] Total time: 2 s, completed 17-Dec-2019 17:37:56

Originally opened against sbt as https://github.com/sbt/sbt/issues/5282.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
dwijnandcommented, Feb 6, 2020

Good news: I release a local version of lm-coursier-shaded and a local version of sbt 1.3.x using it, and this is now fixed.

I learnt that update’s caching doesn’t track lm-coursier-shaded’s version, which is why it was initially looking still unfixed.

Thanks for your help, Alex!!

2reactions
dwijnandcommented, Jan 6, 2020

I should try to get this fix in before 2.0.0 comes out of RC cycle!! (I wouldn’t want 2.0.0 to be “stable” and this change not to be acceptable.) Should I consider this urgent? Do you have an idea of a timeline for 2.0.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ivy dependency as provided - Stack Overflow
I've setup a project with some Ivy dependencies and had to externalize a configuration as JNI (mail/session) in order to do it I...
Read more >
Eclipse global preferences | Apache IvyDE™ - Apache Ant
By default, the classpath container entries are ordered by order of declaration in the ivy.xml. When there are many entries, it can be...
Read more >
Chapter 11. Managing dependencies - Ant in Action
Creates an XML report of all the dependencies and configurations of a module. <ivy:buildlist>, Creates an ordered list of targets to use (for...
Read more >
Mapping of Ivy files to variants should handle configuration ...
Hi folks. I tried to play around with the “ivy mapping to variants” in order to support api vs implementation separation as in ......
Read more >
sbt Reference Manual — sbt Launcher Configuration
... order of precedence: Replace the /sbt/sbt.boot.properties file in the launcher jar; Put a configuration file named sbt.boot.properties on the classpath.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found