2014-01-18 29 views
11

我開始一個Scala項目,我使用SBT和Intellij 13作爲我的IDE。Intellij中的SBT和外部庫

我有以下build.sbt文件,但我似乎無法得到SBT「libraryDependencies」部分中的依賴關係,以在運行「sbt update」之後顯示在「外部庫」中。

以下是我的build.sbt:

name := "myapp-scala" 

version := "1.0" 

scalaVersion := "2.10.3" 

resolvers += "spray repo" at "http://repo.spray.io" 

resolvers += "spray nightlies" at "http://nightlies.spray.io" 

libraryDependencies ++= Seq(
    "com.typesafe.akka" %% "akka-actor"  % "2.2.0", 
    "com.typesafe.akka" %% "akka-slf4j"  % "2.2.0", 
    "ch.qos.logback"  % "logback-classic" % "1.0.13", 
    "io.spray"   % "spray-can"  % "1.2-20130712", 
    "io.spray"   % "spray-routing" % "1.2-20130712", 
    "io.spray"   %% "spray-json"  % "1.2.3", 
    "org.specs2"   %% "specs2"   % "1.14"   % "test", 
    "io.spray"   % "spray-testkit" % "1.2-20130712" % "test", 
    "com.typesafe.akka" %% "akka-testkit"  % "2.2.0"  % "test", 
    "com.novocode"  % "junit-interface" % "0.7"   % "test->default", 
    "org.scalautils" % "scalautils_2.10" % "2.0", 
    "org.scalatest" % "scalatest_2.10" % "2.0" % "test" 
) 

scalacOptions ++= Seq(
    "-unchecked", 
    "-deprecation", 
    "-Xlint", 
    "-Ywarn-dead-code", 
    "-language:_", 
    "-target:jvm-1.7", 
    "-encoding", "UTF-8" 
) 

任何人都可以點我在正確的方向?

enter image description here

+0

你有什麼版本的scala插件和IDEA(13..what?)? –

+0

Scala插件版本0.26.361 InteilliJ版本13.0.1 – binarygiant

+2

我剛剛與IDEA 13.1.1有相同的問題,並且刷新SBT項目爲我做了(查看 - >工具窗口 - > SBT - >刷新所有SBT項目) – LMeyer

回答

10

開始與IDEA 13個工作的最佳方式和sbt項目是這樣的:

  • 請確保您有sbt插件安裝

enter image description here enter image description here enter image description here

  • 如果你hav Ë安裝它,然後簡單地開啓一個SBT項目:

​​ enter image description here

這應該可以解決一切了你,你可以通過SBT控制檯運行命令:

enter image description here

1

要SBT與IntelliJ IDEA的集成則需要使用這個插件: https://github.com/mpeltonen/sbt-idea

它爲您提供了SBT任務gen-idea這將產生與你的項目配置IDEA所需的文件。

+4

不,你不知道。 [在更新的IDEA版本集成應該開箱即用](http://blog.jetbrains.com/scala/2013/11/18/built-in-sbt-support-in-intellij-idea-13/)沒有任何思想轉換。 –

+0

添加IDEA插件後運行gen-idea任務確實有效。我已經閱讀了類似的評論wwhat om-nom-nom提到。至少在我的情況下,我確實需要安裝插件並運行該sbt任務。 – binarygiant

+0

我只是把build.sbt放到一個目錄中,並使用了IDEA中的「導入項目」選項,並且我選擇了build.sbt,並且它似乎爲我處理了其餘部分... – binarygiant

0

我在IntelliJ CE上遇到了同樣的問題14.0.2 build.sbt和project/build.scala文件下的項目/應用程序名稱必須相同。這有助於解決我的問題。

0

什麼@samspired類似說
我剛纔提出的sbt.Project變量的名稱完全一樣的項目模塊名稱的名稱,它解決了這個問題。
轉到文件 - >項目結構 - >模塊
並查看模塊名稱是什麼 - (它不必像項目目錄名稱,但如果你沒有改變它,它可能是)

// this file is in the path of "../Somewhere_in_file_system/MyProjectName/build.sbt" 
lazy val MyProjectName /*this is the module name*/ = (project in file(".")) 
     .settings(
     scalaVersion := "2.11.8", 
     name := "com-company-blabla-myproject" //..... and all the other sbt properties 
    )