Eclipse SBT Dependency Library

584 views Asked by At

After I want to use activator eclipse commond, I should see the project with all jars in SBT Dependency Library container with eclipse project,Just like Maven Dependencies container.How to do it? or do not sbteclipse plugin have the function?

1

There are 1 answers

1
fredfred On

This works for me:

  1. Make sure you have sbteclipse configured as described here.

    You could add this to your sbt configuration at ~/.sbt/0.13/plugins/plugins.sbt:

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "3.0.0")
    
  2. Create a scala app with activator

    activator new minimal-scala minimal-scala
    ...
    OK, application "hello-world" is being created using the "minimal-scala" template.
    ...
    
  3. Compile and run the application

    cd hello-world
    activator run
    ...
    [info] Running com.example.Hello 
    Hello, world!
    [success] Total time: 0 s, completed Jun 11, 2015 8:50:20 PM
    
  4. Create the eclipse project with activator

    activator eclipse
    [info] Set current project to hello-world (in build file:/Users/...)
    [info] About to create Eclipse project files for your project(s).
    [info] Successfully created Eclipse project files for project(s):
    [info] hello-world
    

    This will create the .project and .classpath files that eclipse needs.

  5. Now import the project in Eclipse

    • Select from the menu: File > Import...
    • Type ex in the text field that filters project types and select Existing Projects into Workspace
    • Select your project folder with Browse... button and click Finish

    Now you should see your project in eclipse with all dependencies that are in your sbt build specification (e.g. build.sbt). The sbt dependencies come up in Referenced Libraries.

  6. When you want to change your dependencies, you

    • edit your build.sbt
    • run activator eclipse again
    • select the project in Eclipse and refresh (e.g. hit F5 key or right click and refresh)