문제

In build.sbt.

resolvers += "Repo1" at "http://oss.sonatype.org/content/repositories/releases"

resolvers += "Repo2" at "http://repo1.maven.org/maven2"


libraryDependencies ++= Seq(
  "org.specs2" %% "specs2" % "2.3.11" % "test",
  "org.scalatest" %% "scalatest_2.11" % "2.1.5" % "test"
)


scalacOptions in Test ++= Seq("-Yrangepos")

// Read here for optional dependencies:
// http://etorreborre.github.io/specs2/guide/org.specs2.guide.Runners.html#Dependencies

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

Symptoms:

org.scalatest#scalatest_2.11_2.10;2.1.5: not found

  • With Maven, using the same repositories - everything works perfectly.

Question:

  • What's wrong with sbt, why does it complain all the time?
도움이 되었습니까?

해결책

You should have

libraryDependencies ++= Seq(
  "org.specs2" %% "specs2" % "2.3.11" % "test",
  "org.scalatest" %% "scalatest" % "2.1.5" % "test"
)

in your libraryDependencies (note the removed _2.11).

The reason is that %% will append a correct suffix for you, depending on the Scala version you're using. You can read more in Getting the right Scala version with %%.

If you use groupID %% artifactID % revision rather than groupID % artifactID % revision (the difference is the double %% after the groupID), sbt will add your project's Scala version to the artifact name. This is just a shortcut.

The reason for it are publishing conventions, via SBT documentation:

The underlying mechanism used to indicate which version of Scala a library was compiled against is to append _ to the library's name. For Scala 2.10.0 and later, the binary version is used. For example, dispatch becomes dispatch_2.8.1 for the variant compiled against Scala 2.8.1 and dispatch_2.10 when compiled against 2.10.0, 2.10.0-M1 or any 2.10.x version. This fairly simple approach allows interoperability with users of Maven, Ant and other build tools.

You have added a Scala version yourself and SBT appended one extra, so your artifact name became scalatest_2.11_2.10, which doesn't exist - hence the error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top