6
votes

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 this link. 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.

Any suggestion?

5

5 Answers

5
votes

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

Add this to your plugins.sbt

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

Start the sbt shell and type eclipse.

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

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

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

2
votes

eclipse doesn't have sbt plugin

although sbt has an eclipse plugin

which is a workaround but not proper solution.

which means eclipse doesnt understand build.sbt as it does for pom.xml or build.gradle so 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.

The workaround is as follows

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

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

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

Step3: Open CMD/PowerShell go to D:\sbt\edge run "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.

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.

0
votes

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

  1. downloaded and extracted sbt zip

  2. set path in environment variable

  3. ran sbt int 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 sbt command on cmd you can type >eclipse so that it gets auto downloaded

0
votes

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

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

Add sources & Javadoc jars in your build.sbt

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

In Intellij just use Intellij Scala plugin enter image description here

0
votes

Eclipse SBT for MAC /IOS

  1. Go to your SBT project
  2. go to directory and then inside it go to project folder like

PROJECT_DIR/project/

  1. now find plugins.sbt named file and add this below line

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

  2. Start the sbt shell > sbt and 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