我跟着the official documentation在我的sbt项目中设置了插件:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" %
"2.5.0")
添加到~/.sbt/plugins/plugins.sbt
档案cd
已加入项目并运行sbt
eclipse
我遇到以下错误:
> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse (similar: sbteclipse)
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
我错过了什么?
提前感谢您提供的任何帮助。
$ /opt/sbt-0.13.5/bin/sbt
[warn] The global sbt directory is now versioned and is located at /Users/first.last/.sbt/0.13.
[warn] You are seeing this warning because there is global configuration in /Users/first.last/.sbt but not in /Users/first.last/.sbt/0.13.
[warn] The global sbt directory may be changed via the sbt.global.base system property.
[info] Loading project definition from /Users/first.last/git/myproject/project
[info] Set current project to myproject (in build file:/Users/first.last/git/myproject/)
> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
答案 0 :(得分:23)
我正在使用sbt 0.13.5。
$ sbt --version
sbt launcher version 0.13.5
在 empty 目录中执行sbt about
以检查build / sbt设置。
$ sbt about
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
[info] This is sbt 0.13.5
[info] The current project is {file:/Users/jacek/sandbox/sbteclipse/}sbteclipse 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, net.virtualvoid.sbt.graph.Plugin, com.timushev.sbt.updates.UpdatesPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4
目录中没有文件(忽略target
,因为它在启动时由sbt自动创建,并且可以随时删除。)
$ tree
.
`-- target
1 directory, 0 files
然后我使用sbt
运行sbt shell以确保不存在eclipse
命令。
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse (similar: sbteclipse)
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
我可以重现你的问题。继续设置插件 - 我不关闭sbt shell。
按照文档密切,我打开了~/.sbt/0.13/plugins/plugins.sbt
,如下所示:
$ cat ~/.sbt/0.13/plugins/plugins.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
使用该文件中的插件,我在sbt shell中解雇reload
以加载更改。
> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
> eclipse
[info] About to create Eclipse project files for your project(s).
[info] Updating {file:/Users/jacek/sandbox/sbteclipse/}sbteclipse...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Successfully created Eclipse project files for project(s):
[info] sbteclipse
如您所见,插件已正确加载并生成文件。按照步骤操作,您应该安装插件,没有任何问题。
答案 1 :(得分:5)
对于sbt 0.13及以上
将sbteclipse添加到插件定义文件中。您可以使用:
〜/ .sbt / 0.13 / plugins / plugins.sbt
PROJECT_DIR / project / plugins.sbt
中的项目特定文件addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
答案 2 :(得分:4)
第2-4行中的警告告诉您将插件文件夹从~/.sbt/plugins/plugins.sbt
移至~/.sbt/0.13/plugins/plugins.sbt
。
答案 3 :(得分:1)
<强>解决方案强>
只需使用original documentation(在我的情况下为F23)更新到最新的sbt
(在我的情况下为sbt-0.13.9-1.noarch
):
curl https://bintray.com/sbt/rpm/rpm \
| sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum install --best --allowerasing sbt
再次从项目目录中重试(第一次花了大约10分钟来获取依赖项):
sbt eclipse
原始问题
这似乎是(至少)sbt-0.13.1
在(至少)Linux上的问题。
我在Linux F23上使用了默认包:
scala-2.10.4-8.fc23.noarch
java-1.8.0-openjdk-1.8.0.91-6.b14.fc23.x86_64
sbt-0.13.1-8.fc23.noarch
没有排列(~/.sbt/plugins/plugins.sbt
,~/.sbt/0.13/plugins/plugins.sbt
,PROJECT_DIR/project/plugins.sbt
,...),配置选项有效。
答案 4 :(得分:1)
Eclipse没有sbt插件,尽管sbt具有eclipse插件
这是一种解决方法,但不是正确的解决方案。
这意味着 eclipse不能像pom.xml或build.gradle那样理解build.sbt 因此,如果我们在build.sbt文件中的eclipse项目中更改依赖关系,eclipse将无法理解它,也不会更改项目依赖关系中的依赖关系。因此,每当您修改任何依赖关系时,都必须执行以下步骤。
解决方法如下(我使用了 windows )
第1步:从https://www.scala-sbt.org/release/docs/Setup.html下载并安装sbt 对于Windows,https://piccolo.link/sbt-1.2.8.msi非常简单
第二步:创建一个文件夹,说D:\ sbt \ edge 现在在这里创建一个build.sbt文件 您可以使用以下内容作为内容,并进行相应的更改
name := "edge"
version := "0.1"
scalaVersion := "2.11.8"
val sparkVersion="2.4.0"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-mllib" % sparkVersion % "runtime",
"org.apache.spark" %% "spark-streaming" % sparkVersion % "provided",
"org.apache.spark" %% "spark-hive" % sparkVersion % "provided",
"org.apache.spark" %% "spark-catalyst" % sparkVersion % Test,
"org.apache.spark" %% "spark-graphx" % sparkVersion,
"org.apache.spark" %% "spark-repl" % sparkVersion % "provided",
"org.apache.spark" %% "spark-yarn" % sparkVersion,
"org.apache.spark" %% "spark-mllib-local" % sparkVersion,
//"org.apache.spark" %% "spark-streaming-kafka" % "1.6.3",
//"org.apache.spark" %% "spark-streaming-twitter" % "1.6.3",
"ch.qos.logback" % "logback-classic" % "1.1.3"
)
现在创建这些嵌套文件夹src和main,例如-> D:\ sbt \ spark \ src \ main
第3步:打开CMD / PowerShell转到D:\ sbt \ edge 运行“ sbt软件包”
第4步:在我的情况下,进入您主目录中的.sbt和正确版本的plugins文件夹中的C:\ Users \ xxxx.sbt \ 1.0 \ plugins 如果您已经有一个plugins.sbt文件,请添加以下行 addSbtPlugin(“ com.typesafe.sbteclipse”%“ sbteclipse-plugin”%“ 5.2.4”) 如果没有,请创建并添加行。
第5步:返回CMD / PowerShell,运行sbt eclipse。它将为Eclipse项目创建必要的文件。 第6步:打开一个Eclipse工作区,并将该项目导入为现有项目。
答案 5 :(得分:0)
答案 6 :(得分:0)
要在scala eclipse上创建sbt项目,您需要做一些事情:
答案 7 :(得分:-1)
通过将sbteclipse-plugin form 4.0降级为2.5.0,我能够摆脱同样的错误