Electric Coffee
Electric Coffee

Reputation: 12144

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.

Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.

The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.

Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.

I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...

So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?

Upvotes: 1

Views: 1719

Answers (3)

Andrew Norman
Andrew Norman

Reputation: 910

I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).

If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.

To enable:

  1. type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
  2. right click on your project. Choose the Ivy -> enable Ivy dependency management option
  3. go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.

Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

Upvotes: 0

Iulian Dragos
Iulian Dragos

Reputation: 5712

Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:

  • use the Eclipse builder
    • Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
    • Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
  • use Sbt on the command line (make sure to disable auto-building in Eclipse)
    • Pros: can handle complex builds, classpath is always up to date
    • Cons: no integration (see above)
  • use Activator
    • Same Pros and Cons as Sbt, but with a pretty UI

We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.

Upvotes: 1

Alexey Romanov
Alexey Romanov

Reputation: 170909

There may be some movement in this direction in the future, but for now there is no such plugin.

Upvotes: 1

Related Questions