Search code examples
scalaintellij-ideasbtsbt-idea

sbt version and scala version. project configuration for intellij idea with sbt-idea plugin


I follow these steps to configure a project for IntelliJ idea.

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")

I use sbt-idea for sbt version 0.12 with fixed bug for Idea.

When I type sbt in my project's directory, I noticed that it uses scala 2.9.2.. but I'm going to use scala 2.10.1 for my project.

Questions:

Does it make sense which scala version to use for plugin(s) (~/.sbt/plugins)-compilation, or I should use one/same scala version for everything? Can I change scala version for plugins?

So, I created ~/.sbt/plugin/build.sbt file with mentioned content.


Solution

  • Actually I got it.

    1. if you have a project with build.sbt (that uses 2.10.1 scala) file - as soon as you type sbt.. all dependencies will be downloaded into ~/.sbt folder - even scala compiler will be downloaded there (~/.sbt/boot). It could be even several version of scala: 2.10.1 and 2.9.2 for example.

    2. and about sbt-idea and ~/sbt/plugins .. it could any scala version - depending on its build.sbt file, for example in my case:

    resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

    addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0-SNAPSHOT")
    

    I should notice if try different version.. like 1.1.0-M2-TYPESAFE it will not work.. (at least in my case) - gen-idea command is not available then. I do not know why. I guess it should.

    Also if you do not point resolvers += - it will will not work.. but it it will not tell you about that..

    This plugin is using scala 2.9.2 - we can not see it here, but we can see it from that outputs it produces while installing/downloading. That's why we have ~/.sbt/boot/scala-2.9.2/ as a result.

    In any case we should not care about it. It is handled by sbt.

    When you converted your sbt-project into your intellij-idea project by typing gen-idea in sbt console, as the result your IDE project will be referencing to ~/.sbt/scala but not to your somewhere-installed-scala.. So even no need to pointing the scala location - that sbt-idea sbt's plugin will do all the work. And that's good!

    That's the answer I wanted to get. One gets/understands it by trying it.