sbt-idea icon indicating copy to clipboard operation
sbt-idea copied to clipboard

Failure to resolve Scala Versions specific dependency

Open ghost opened this issue 11 years ago • 3 comments

In our Build.scala file we are setting

scalaVersion := “2.10.2"

Further down the file, we declare the specs2 dependency like so

libraryDependencies ++= Seq( "org.specs2" %% "specs2" % "1.5" % “test” withSources() )

%% in this case denotes a Scala version specific dependency, omitting this information can result in lots of errors about invalid class files, etc.

We also use the sbt-idea SBT plugin to generate our Intellij configuration.

I fire up SBT, go to the console and issue the command, ‘test’.

The test classes are compiled and run, it works without problem.

I run gen-idea to generate my Intellij configuration, and open the project using Intellij.

Intellij flags all the code as red, it can’t find the specs2 dependency, although it can find all of it’s dependencies (scalaz etc).

I repeat this process ad-nauseum, trying different versions of specs2, deleting ~/.ivy and various system caches.

(I actually simplified the introduction, the test code started off broken which made things even more complicated).

Eventually I discovered that although SBT could correctly resolve the version of specs2 to add to the classpath , the sbt-idea plugin could not.

My temporary, hacky workaround is to declare the specs dependency in the following manner.

libraryDependencies ++= Seq( "org.specs2" % "specs2_2.10" % "2.3.4" withSources() )

Note how I specify the dependency as "org.specs2" % , the Scala version is now hard-coded and will break in the future.

ghost avatar Dec 02 '13 16:12 ghost

as far as I can see specs2 1.5 was never compiled with scala 2.10

i think if you say "org.specs2" %% "specs2" % "2.3.4" withSources() it will work fine

jozic avatar Dec 02 '13 17:12 jozic

It seems you are correct, I can no longer reproduce the issue.

ghost avatar Dec 02 '13 17:12 ghost

good, let's close this issue then

jozic avatar Dec 02 '13 17:12 jozic