Di Zou
Di Zou

Reputation: 4619

How do I change intellij idea to compile with scala 2.11?

I am using Intellij Idea 13.1.4. I have a scala sbt project. It is currently being compiled with Scala 2.10. I would like to change this to Scala 2.11. In my build.sbt, I have:

libraryDependencies ++= Seq(
  "org.scala-lang" % "scala-compiler" % "2.11.0",
  ...
)

When I build my project, it still builds as a Scala 2.10 project.

Also, under my Project Settings->Modules->Scala->Facet 'Scala'->Compiler library, Intellij still shows scala-compiler-bundle:2.10.2. There is no option for a 2.11.x bundle. How would I get an option for Scala 2.11.x?

Thanks!

Upvotes: 31

Views: 72597

Answers (6)

Benas
Benas

Reputation: 2332

As of intelliJ version: 2021.1.1 go to:

File->Project structure->Platform settings->Global libraries

press "+" and add/download Scala sdk

Upvotes: 8

aya_cool
aya_cool

Reputation: 57

add this to your build.sbt file

scalaVersion='2.11.11'

Upvotes: 2

NOTiFY
NOTiFY

Reputation: 1401

In IntelliJ 2016.x you upgrade Scala by

Ensure Scala Plugin up to date.

Then by going to:

File | Other Settings | Default Project Structure | Global Libraries

Click the + button at the top left hand side of the Window

Select Scala SDK

Choose the version you want to install.

Upvotes: 41

traceformula
traceformula

Reputation: 391

I have had the same issue as you. I added scala version 2.11 in my build.sbt. After that, I removed the default scala SDK by

  • Go to File > Other Settings > Default Project Structures > Platform Settings > Global Libraries
  • Remove scala-sdk-2.10.6

Hence, IntelliJ will pick up my project scala SDK (after I do sbt assembly)

Upvotes: 11

jrp
jrp

Reputation: 201

In .iml file, there is entry for scala sdk library as shown below:

<orderEntry type="library" name="scala-sdk-2.10.6" level="application" />
<orderEntry type="library" name="scala-sdk-2.11.8" level="application" />

comment or remove the scala sdk version entry that you dont want.

Upvotes: 7

Javi12
Javi12

Reputation: 163

You'll have to add first a new scala-compiler in File > Other Settings > Default Project Structure…

In scala-compiler include:

<SCALA_HOME>/lib/scala-compiler.jar
<SCALA_HOME>/lib/scala-library.jar
<SCALA_HOME>/lib/scala-reflect.jar

Replace with your scala installation directory.

Go to File > Project Settings… and select the newly created compiler-library in "Compiler library". You may have to select Scala 2.11 in Language Level as well.

Upvotes: 0

Related Questions