Via File/New Project in Intellij 13.1.2, how do I change it to use Scala 2.11.1 (as opposed to 2.10.2)...

I'm brand new to Intellij. I also have no SBT experience to speak of. I have downloaded Intellij 13.1.2 and created a small sample project to get my bearings with the Scala plugin (choosing the SBT option).

Now, I would like to begin using Intellij more seriously. So, my first goal was to start a new Scala project on 2.11, produce a small bit of Scala code and then use ScalaTest to write tests for my new Scala code. After spending about an hour trying to figure out the myriad of possible pathways to achieve this with Intellij 13.1.2, I realize that I can end up on a bunch of tangents. So, rather than spend time on tangents, I thought I would ask for help here.

I have created a new Scala project called "PublicDomain". And it is showing as the second item in "Exterenal Libraries" as "SBT: org.scala-lan:scala-library:2.10.2". Here are the things I would like to achieve and have thus far not been able to figure out:

  1. How do I switch this Intellij project to begin using Scala 2.11.1? From my research, I think it likely has something to do wtih build.sbt, but I don't know exactly how or what.
  2. How do I add ScalaTest to this project?
  3. Once ScalaTest is added, how do I go about executing the tests?


I have been using Eclipse for years with Java and Scala. I've used Ant for all my Java builds. And all of my Scala has been very simple command line apps. So, I have not had to learn SBT yet.  


My first foray into Intellij has been a very positive experience. What I am now realizing is just how high the barrier for entry to Scala is, especially in terms of all the versioning fragility between multiple IDEs, major point versions of Scala and all the numerous libraries and frameworks. I have some ideas on how to help with that. But first things first, I must get a simple new project framework seeded and bootstrapped in Intellij. Any guidance on this you can offer would be greatly appreciated.  


Thank you.

1 comment

Answers:

  1. How do I switch this Intellij project to begin using Scala 2.11.1?:
    1. modify the build.sbt file by appending a line containing [scalaVersion := "2.11.1"] (the text sans the square brackets)
  2. How do I add ScalaTest to this project?
    1. modify the build.sbt file by appending a line containing [libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.1.7" % "test"] (the text sans the square brackets)
  3. Once ScalaTest is added, how do I go about executing the tests?
    1. go here and follow the instructions after the header "Running ScalaTest"


build.sbt before:

<file_contents>

name := "PublicDomain"

version := "1.0"

</file_contents>


build.sbt after:

<file_contents>

name := "PublicDomain"

version := "1.0"

scalaVersion := "2.11.1"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.1.7" % "test"

</file_contents>




0

Please sign in to leave a comment.