3

I am learning Scala and downloaded IntelliJ Idea. I installed the Scala plugin and was instantly given the 2.12 version. Now I am trying to downgrade to 2.11 because I need this version to follow along a Coursera class I am taking.

I am having the same "UNRESOLVED DEPENDENCIES" shown in the link below: SBT project refresh failed [IntelliJ, Scala, SBT]

I tried to solve my problem by doing what @Haspemulator suggested, but I'm still getting error messages. Here is a screenshot of what I have now:

enter image description here

(Notice that there is a folder called scala-2.12)

Community
  • 1
  • 1
pandasCat
  • 159
  • 2
  • 11
  • 1
    I solved the problem I was having with line 6 and 7 in the picture above. I first ran lines 1-5. Once those were done, I ran line 7. – pandasCat Dec 28 '16 at 22:34
  • 1
    Also in line 7 should say: `libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % Test` Updated question: What Scala version am I using for this project? Am I using 2.11.8 or 2.12? – pandasCat Dec 28 '16 at 22:41
  • make sure you are using all the dependencies for scala 2.11 and not 2.12. https://mvnrepository.com/artifact/org.scalatest/scalatest_2.11/3.0.0 – pedrorijo91 Dec 29 '16 at 09:14
  • The `scala-2.12` folder doesn't matter. It was likely created automatically before you added `scalaVersion` and not deleted afterwards. Just don't forget to reimport your project if you didn't set `import automatically` when creating it. – Alexey Romanov Dec 29 '16 at 12:53

2 Answers2

1

The error you get states that "Cannot add dependency ... to configuration "Test" because this configuration doesn't exist!" There's no such predefined configuration as "Test". There's only "test" (lower case). Try to use it instead.

Alexandr Nikitin
  • 7,258
  • 2
  • 34
  • 42
  • 1
    Thank you. Yes that was one of my problems. My main question now is: Is it necessary to downgrade from Scala 2.12 to 2.11.8 or does the line `scalaVersion := "2.11.8"` let me switch to the older Scala version in this project? – pandasCat Dec 28 '16 at 22:45
  • 3
    `scalaVersion` should do it, and the `%%` on line 7 means you get the 2.11 version of scalatest too. – HTNW Dec 29 '16 at 01:43
1

CatherineAlv has already solved the problem. I am just segregating the steps together.

I too faced this problem while setting up scala for coursera course "Functional Programming Principles in Scala". By default build.sbt was showing scalaVersion as 2.12.x but I needed 2.11.x for the course. This can be easily solved in two steps:

  1. Change the scalaVersion in build.sbt. The code would look like after change:

     name := "Example"
     version := "1.0"
     scalaVersion := "2.11.8"
    

    Build it.

  2. Add the libraryDependencies to build.sbt. The code would now look like this:

     name := "Example"
     version := "1.0"
     scalaVersion := "2.11.8"
     libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.6" % "test"
    

    Build again.

This should solve it.

Adarsh
  • 111
  • 2