IntelliJ: what difference between "SBT Console" and "SBT Shell"? - scala

In the IntelliJ I see two tool windows: SBT Console and SBT Shell. What is the difference between these tools?

You may have installed both scala and sbt plugins. The newer version of scala plugin has sbt as part of it.
sbt console is the sbt plugin -- click start you will enter into sbt interactive mode.
sbt shell is part of the scala plugin, which is similar to the above mentioned sbt console and can autocomplete commands.
Here is a description: https://blog.jetbrains.com/scala/2017/03/23/scala-plugin-for-intellij-idea-2017-1-cleaner-ui-sbt-shell-repl-worksheet-akka-support-and-more/

SBT Console plugin is deprecated in favour of IntelliJ Scala Plugin. Deprecation notice states:
JetBrains have recently added support for an SBT console to the
IntellIJ Scala Plugin. This is now the recommended way to use SBT
within IntellIJ. No new releases of this plugin are planned.

Related

Run Scala Dotty project using Intellij IDE

I created a basic Scala Dotty project using Dotty template and import the project to IntelliJ IDE.
Everything works fine when I use the sbt command line.
When I try to build or run it inside IntelliJ IDE, I got following errors:
Error:scalac: Multiple 'scala-library*.jar' files (scala-library-0.9.0-RC1.jar, scala-library-2.12.6.jar) in Scala compiler classpath in Scala SDK sbt: ch.epfl.lamp:dotty-library_0.9:0.9.0-RC1:jar
Any ideas how to solve this?
IDE support for Dotty
Currently, the only IDE we officially support is Visual Studio Code.
Anyway when you import a project to IntelliJ IDEA check "use sbt shell". At least for me after that a test project compiles and runs with Ctrl+Shift+F10.
It's possible that not everything will work. For example Dotty macros don't but if I compile and run manually then they do.

Can not download jars when building scala project with sbteclipse?

As shown in the picture, when I build scala project with sbteclipse and import to eclipse, when changing build.sbt , jars are downloaded to my computer but not to scalaProject. I do not know why. Can someone help me?
scala version: 2.11.8
sbt version: 0.13.15
stbeclipse:5.1.0
I assume that you're using the Scala IDE plugin for Eclipse, correct?
The sbteclipse SBT plugin merely provides a command to generate an Eclipse Scala project from the SBT build. Before using Eclipse, you're supposed to issue the following command (from the command line) to SBT:
sbt eclipse
This should generate the project files for your Eclipse project. After executing this command, you can open your project using Eclipse (with the Scala IDE plugin).
Note that, at present, the Scala IDE Eclipse plugin does not support SBT build files. That is, if you change your SBT build file, then Eclipse will be none the wiser, until you re-run the above command.
You might want to consider switching to IntelliJ IDEA (instead of Eclipse) which has a full-featured Scala plugin that fully supports SBT builds, including downloading any dependencies. For my money (both IDEs are free) IntelliJ is light-years ahead of Eclipse for Scala development.

IntelliJ, Scala plugin and h2-browser

Is there any way to add the h2-browser flag in a Play 2 IntelliJ run configuration? I prefer not to manually run sbt and / or and sbt console.

How to execute SBT plugin's tasks from within IntelliJ IDEA CE?

I use IntelliJ IDEA 13.1 Community Edition with the Scala plugin 0.32.593.
What's the recommended way to execute a SBT plugin's tasks, say dependencyUpdates from sbt-updates?
In version 15 of IntelliJ IDEA, using Scala Plugin version 2.0, you can run SBT tasks by adding a run configuration.
First add a new run configuration by clicking on Run -> Edit Configurations. Then click the + button to add a new configuration and choose SBT Task form the list
Now provide the list of tasks separated by space in Tasks input box:
NOTE IntelliJ IDEA and the Scala and sbt plugins have improved since and you may want to read How to run sbt-assembly tasks from within IntelliJ IDEA? instead.
I worked it around with the Embedded Terminal plugin that shipped with the version of IDEA.
Alt+F12 (or Tools > Open Terminal) to open a terminal window and then sbt dependencyUpdates inside.
It does require a local installation of SBT.
Unless there has been a recent change (in 13.1), SBT plugin doesn't support running sbt tasks.
See comments here http://blog.jetbrains.com/scala/2013/11/18/built-in-sbt-support-in-intellij-idea-13/
You will have to run these two commands to run SBT in the terminal:
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
java $SBT_OPTS -jar `<SBT inatall>`/bin/sbt-launch.jar "$#"

How to Point Intellij at SBT Libraries for Scala Project

I'm trying to use this example: https://github.com/spray/spray-template for a Spray project, however I can't figure out how to point Intellij at the dependencies downloaded via SBT.
Any suggestions?
If you're using IntelliJ version 13, you need only the Scala plug-in (which has built-in SBT support); just open the project by selecting the build.sbt file.
Use this SBT plugin to generate Intellij IDEA project files: https://github.com/mpeltonen/sbt-idea
Add SBT plugin for creating IntelliJ IDEA projects in your ~/.sbt/0.xx/plugins/build.sbt or PROJECT_DIR/project/plugins.sbt. Use gen-idea command to create an IntelliJ project and open the project in IntelliJ. That should be it.