3

我正在创建一个新的 SBT 项目,这里是我的 SBT 文件的内容:

build.properties

sbt.version=0.12.0

插件.sbt

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

构建.sbt

name := "peroo"

version := "0.1-SNAPSHOT"

scalaVersion := "2.10.0"

resolvers ++= Seq(
  Classpaths.typesafeResolver,
  "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
  "Sonatype releases"  at "https://oss.sonatype.org/content/repositories/releases/"
)

libraryDependencies ++= Seq(
  compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.0"),
  "com.google.guava" % "guava" % "13.0"
)

scalacOptions ++= Seq("-P:continuations:enable", "-deprecation", "-unchecked", "-feature")

autoCompilerPlugins := true

这是我尝试sbt在项目目录根目录中启动时遇到的错误:

➜  peroo  sbt 
[info] Loading project definition from /Users/rahulphulore/projects/rahul/peroo/project
[info] Updating {file:/Users/rahulphulore/projects/rahul/peroo/project/}default-941135...
[info] Resolving com.google.guava#guava;13.0 ...
[info] Resolving com.github.mpeltonen#sbt-idea;1.2.0 ...
[warn]  module not found: com.github.mpeltonen#sbt-idea;1.2.0
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.github.mpeltonen/sbt-idea/scala_2.10/sbt_0.12/1.2.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/com.github.mpeltonen/sbt-idea/scala_2.10/sbt_0.12/1.2.0/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/rahulphulore/.ivy2/local/com.github.mpeltonen/sbt-idea/scala_2.10/sbt_0.12/1.2.0/ivys/ivy.xml
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.github.mpeltonen/sbt-idea/scala_2.10/sbt_0.12/1.2.0/ivys/ivy.xml
[warn] ==== Sonatype snapshots: tried
[warn]   http://oss.sonatype.org/content/repositories/snapshots/com/github/mpeltonen/sbt-idea_2.10_0.12/1.2.0/sbt-idea-1.2.0.pom
[warn] ==== Sonatype releases: tried
[warn]   https://oss.sonatype.org/content/repositories/releases/com/github/mpeltonen/sbt-idea_2.10_0.12/1.2.0/sbt-idea-1.2.0.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/github/mpeltonen/sbt-idea_2.10_0.12/1.2.0/sbt-idea-1.2.0.pom
[info] Resolving org.scala-sbt#sbt;0.12.0 ...
[info] Resolving org.scala-sbt#main;0.12.0 ...
[info] Resolving org.scala-sbt#actions;0.12.0 ...
[info] Resolving org.scala-sbt#classpath;0.12.0 ...
[info] Resolving org.scala-sbt#launcher-interface;0.12.0 ...
[info] Resolving org.scala-lang#scala-library;2.10.0 ...
[info] Resolving org.scala-sbt#interface;0.12.0 ...
[info] Resolving org.scala-sbt#io;0.12.0 ...
[info] Resolving org.scala-sbt#control;0.12.0 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.0 ...
[info] Resolving org.scala-lang#scala-reflect;2.10.0 ...
[info] Resolving org.scala-sbt#completion;0.12.0 ...
[info] Resolving org.scala-sbt#collections;0.12.0 ...
[info] Resolving jline#jline;1.0 ...
[info] Resolving org.scala-sbt#api;0.12.0 ...
[info] Resolving org.scala-sbt#compiler-integration;0.12.0 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.12.0 ...
[info] Resolving org.scala-sbt#logging;0.12.0 ...
[info] Resolving org.scala-sbt#process;0.12.0 ...
[info] Resolving org.scala-sbt#compile;0.12.0 ...
[info] Resolving org.scala-sbt#persist;0.12.0 ...
[info] Resolving org.scala-tools.sbinary#sbinary_2.9.0;0.4.0 ...
[info] Resolving org.scala-sbt#classfile;0.12.0 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.12.0 ...
[info] Resolving org.scala-sbt#ivy;0.12.0 ...
[info] Resolving org.apache.ivy#ivy;2.3.0-rc1 ...
[info] Resolving com.jcraft#jsch;0.1.46 ...
[info] Resolving commons-httpclient#commons-httpclient;3.1 ...
[info] Resolving commons-logging#commons-logging;1.0.4 ...
[info] Resolving commons-codec#commons-codec;1.2 ...
[info] Resolving org.scala-sbt#run;0.12.0 ...
[info] Resolving org.scala-sbt#task-system;0.12.0 ...
[info] Resolving org.scala-sbt#tasks;0.12.0 ...
[info] Resolving org.scala-sbt#tracking;0.12.0 ...
[info] Resolving org.scala-sbt#cache;0.12.0 ...
[info] Resolving org.scala-sbt#testing;0.12.0 ...
[info] Resolving org.scala-sbt#test-agent;0.12.0 ...
[info] Resolving org.scala-tools.testing#test-interface;0.5 ...
[info] Resolving org.scala-sbt#command;0.12.0 ...
[info] Resolving org.scala-sbt#compiler-interface;0.12.0 ...
[info] Resolving org.scala-sbt#precompiled-2_8_2;0.12.0 ...
[info] Resolving org.scala-sbt#precompiled-2_10_0-m4;0.12.0 ...
[info] Resolving org.scala-lang.plugins#continuations;2.10.0 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.github.mpeltonen#sbt-idea;1.2.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.github.mpeltonen:sbt-idea:1.2.0 (sbtVersion=0.12, scalaVersion=2.10)
[warn] 
sbt.ResolveException: unresolved dependency: com.github.mpeltonen#sbt-idea;1.2.0: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:211)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:102)
    at sbt.IvySbt.liftedTree1$1(Ivy.scala:49)
    at sbt.IvySbt.action$1(Ivy.scala:49)
    at sbt.IvySbt$$anon$3.call(Ivy.scala:58)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:75)
    at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:58)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:79)
    at xsbt.boot.Using$.withResource(Using.scala:11)
    at xsbt.boot.Using$.apply(Using.scala:10)
    at xsbt.boot.Locks$GlobalLock.liftedTree1$1(Locks.scala:51)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:51)
    at xsbt.boot.Locks$.apply0(Locks.scala:30)
    at xsbt.boot.Locks$.apply(Locks.scala:27)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:58)
    at sbt.IvySbt.withIvy(Ivy.scala:99)
    at sbt.IvySbt.withIvy(Ivy.scala:95)
    at sbt.IvySbt$Module.withModule(Ivy.scala:114)
    at sbt.IvyActions$.update(IvyActions.scala:121)
    at sbt.Classpaths$$anonfun$work$1$1.apply(Defaults.scala:949)
    at sbt.Classpaths$$anonfun$work$1$1.apply(Defaults.scala:947)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$54.apply(Defaults.scala:970)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$54.apply(Defaults.scala:968)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:35)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:972)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:967)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:45)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:975)
    at sbt.Classpaths$$anonfun$45.apply(Defaults.scala:855)
    at sbt.Classpaths$$anonfun$45.apply(Defaults.scala:852)
    at sbt.Scoped$$anonfun$hf10$1.apply(Structure.scala:586)
    at sbt.Scoped$$anonfun$hf10$1.apply(Structure.scala:586)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$5.work(System.scala:71)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:238)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.github.mpeltonen#sbt-idea;1.2.0: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
➜  peroo  

可能是什么问题?

编辑:

这是我的项目目录结构的样子:

在此处输入图像描述

4

4 回答 4

2

我在 Mac Mountain Lion 上添加了~/.sbt/plugins/plugins.sbt. 它可以工作并且依赖项不再失败。我认为您需要在 scala 版本之外使用它,并cala-reflect.jar在 IDE 内手动将 s 添加到您的路径中以使其正常工作。

于 2013-02-20T12:37:39.193 回答
2

根据项目发布页面,sbt-idea 的最新版本是 1.5.1,它是为sbt0.11和.0.120.13

然而,在http://repo1.maven.org/maven2/com/github/mpeltonen/中有更新版本的插件可用1.5.2

您应该能够在以下行中使用该插件project/sbt-idea.sbt

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

一种更简单但更慢的方法来指定正确的版本号 -latest.integration用于版本部分。

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

来自Ivy 文档的latest.integration关于's 性能的摘录:

请注意,为了找到具有适当状态的最新修订版,Ivy 必须从最后一个解析存储库中的所有 ivy 文件,直到找到这样的修订版。因此,如果分辨率变慢,请不要感到惊讶。

请注意,自从您提出问题以来,IntelliJ IDEA 和 sbt 都得到了改进,并且目前对插件的需求较少,如 IDEA “新版本的 Scala 插件内置对 SBT 的支持,具有代码完成和依赖项导入。”

于 2013-12-29T14:51:47.007 回答
2

您的plugins.sbt文件必须是全局的,如@alex23 所示,或者位于项目的project/子目录中。这样,它适用于 SBT,而不适用于您自己的代码,可能不需要它。

于 2013-02-20T14:49:00.887 回答
0

我显然遇到了同样的问题,但是我“修复”了一个更新的版本(1.5.X),只是降级到 gen-idea 插件的 1.4.0 版本。

cat ~/.sbt/plugins/build.sbt
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")
于 2013-11-10T08:16:41.387 回答