eclipse 如何在eclipse中添加sbteclipse插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25995664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:00:37  来源:igfitidea点击:

how to add sbteclipse plugin in eclipse

eclipsescalasbteclipse

提问by swaheed

I am using sbt 0.13 and I would like to add sbteclipse plugin so that eclipse import my sbt project and I can write my scala code easily. While searching on the internet I got thislink. I read all the instruction that to make plugins.sbt file and added plugin in it but I am confused about what to download and after downloading this zip file what should I do next please.

我正在使用 sbt 0.13,我想添加 sbteclipse 插件,以便 eclipse 导入我的 sbt 项目,我可以轻松编写我的 Scala 代码。在互联网上搜索时,我得到了这个链接。我阅读了制作 plugins.sbt 文件并在其中添加插件的所有说明,但我对下载什么以及下载此 zip 文件后我接下来应该做什么感到困惑。

Any suggestion?

有什么建议吗?

采纳答案by bmaderbacher

There is no need to download anything by hand. Just follow the instructions for sbt 0.13 and higher.

无需手动下载任何内容。只需按照 sbt 0.13 及更高版本的说明进行操作即可。

Add this to your plugins.sbt

将此添加到您的 plugins.sbt

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")

Start the sbt shell and type eclipse.

启动 sbt shell 并输入 eclipse。

This automaticly downloads the plugin and creates the eclipse project files for you.

这会自动下载插件并为您创建 eclipse 项目文件。

Now you can just import the project via the import project wizard in eclipse.

现在您可以通过 eclipse 中的导入项目向导导入项目。

You can find this instructions at the README file on github: https://github.com/typesafehub/sbteclipse/blob/master/README.md

您可以在 github 上的 README 文件中找到此说明:https: //github.com/typesafehub/sbteclipse/blob/master/README.md

回答by Koushik Paul

eclipse doesn't have sbt plugin

eclipse 没有 sbt 插件

although sbt has an eclipse plugin

虽然 sbt 有一个 eclipse 插件

which is a workaround but not proper solution.

这是一种解决方法,但不是正确的解决方案。

which means eclipse doesnt understand build.sbt as it does for pom.xml or build.gradleso if we change a dependency in our eclipse project in build.sbt file, eclipse will not understand it, and will not change the dependency in the project dependencies.So you have to do the below steps everytime u modify any dependency.

这意味着eclipse 不像 pom.xml 或 build.gradle那样理解 build.sbt,所以如果我们在 build.sbt 文件中更改 eclipse 项目中的依赖项,eclipse 将无法理解它,也不会更改项目中的依赖项依赖项。因此,每次修改任何依赖项时都必须执行以下步骤。

The workaround is as follows

解决方法如下

Step1:Download and install sbt from https://www.scala-sbt.org/release/docs/Setup.htmlfor windows it is pretty straight forward https://piccolo.link/sbt-1.2.8.msipretty straight forward

步骤 1:https://www.scala-sbt.org/release/docs/Setup.html下载并安装 sbt for windows 非常简单 https://piccolo.link/sbt-1.2.8.msi非常简单向前

Step2:Create a folder say D:\sbt\edge now create a build.sbt file here You can use the following as the content, change it accordingly

Step2:创建一个文件夹说 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"
)

now create these nested folders src and main like -> D:\sbt\spark\src\main

现在创建这些嵌套文件夹 src 和 main 像 -> D:\sbt\spark\src\main

Step3:Open CMD/PowerShell go to D:\sbt\edge run "sbt package"

Step3:打开 CMD/PowerShell 到 D:\sbt\edge 运行“sbt package”

Step4:Go inside .sbt in ur home directory and in plugins folder of the correct version in my case C:\Users\xxxx.sbt\1.0\plugins if u have a plugins.sbt file already, add the following line addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")if not, create and add the line.

步骤 4:进入 .sbt 在你的主目录和正确版本的插件文件夹中,在我的情况下 C:\Users\xxxx.sbt\1.0\plugins 如果你已经有一个 plugins.sbt 文件,添加以下行addSbtPlugin(" com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")如果不是,请创建并添加该行。

Step5:Go back to CMD/PowerShell , run sbt eclipse. It will create the necessary files for eclipse project. Step6:Open an eclipse workspace, and import this project as an existing project.

第五步:回到 CMD/PowerShell ,运行 sbt eclipse。它将为 eclipse 项目创建必要的文件。 Step6:打开一个eclipse工作区,把这个工程作为已有工程导入。

回答by HariKishore

Eclipse SBT for MAC /IOS

用于 MAC/IOS 的 Eclipse SBT

  1. Go to your SBT project
  2. go to directory and then inside it go to project folder like
  1. 转到您的 SBT 项目
  2. 转到目录,然后在其中转到项目文件夹,例如

PROJECT_DIR/project/

PROJECT_DIR/项目/

  1. now find plugins.sbtnamed file and add this below line

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")

  2. Start the sbt shell > sbtand then type > eclipse

  3. This automatically downloads the plugin and creates the eclipse project files for you and import this project as existing project to your eclipse

  1. 现在找到plugins.sbt命名文件并将其添加到以下行

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")

  2. 启动 sbt shell > sbt,然后输入 >eclipse

  3. 这会自动下载插件并为您创建 eclipse 项目文件,并将此项目作为现有项目导入您的 eclipse

回答by satish sasate

I have followed below steps for installing sbt on my windows machine

我已按照以下步骤在我的 Windows 机器上安装 sbt

  1. downloaded and extracted sbt zip

  2. set path in environment variable

  3. ran sbtint cmd (it did take sometime to download some dependencies)

    On windows OS you will find the sbt folder in your user profile folder under C:\Users\UserName.sbt\1.0

  4. If plugins folder is not present in above directory then you can create one and also create plugins.sbt file in this new folder(C:\Users\UserName.sbt\1.0\plugins)

  5. add below command/text in plugins.sbt and save it addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")

  6. now when you run sbtcommand on cmd you can type >eclipseso that it gets auto downloaded

  1. 下载并解压 sbt zip

  2. 在环境变量中设置路径

  3. 运行sbtint cmd (下载一些依赖项确实需要一些时间)

    在 Windows 操作系统上,您将在C:\Users\UserName.sbt\1.0下的用户配置文件文件夹中找到 sbt 文件夹

  4. 如果插件文件夹不在上面的目录中,那么你可以创建一个并在这个新文件夹中创建 plugins.sbt 文件(C:\Users\UserName.sbt\1.0\plugins)

  5. 在 plugins.sbt 中添加以下命令/文本并保存 addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")

  6. 现在,当您在 cmd 上运行sbt命令时,您可以键入 > eclipse以便自动下载

回答by Narayan Yerrabachu

To create Eclipse Project defination, include the plugin dependency in PROJECT_DIR/project/plugins.sbt.

要创建 Eclipse 项目定义,请在 PROJECT_DIR/project/plugins.sbt 中包含插件依赖项。

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") 

Add sources & Javadoc jars in your build.sbt

在 build.sbt 中添加源代码和 Javadoc jar

EclipseKeys.withSource := true
EclipseKeys.withJavadoc := true

In Intellij just use Intellij Scala plugin enter image description here

在 Intellij 中只使用 Intellij Scala 插件 在此处输入图片说明