8

I use IntelliJ IDEA 13.1 Community Edition with the Scala plugin 0.32.593.

enter image description here

What's the recommended way to execute a SBT plugin's tasks, say dependencyUpdates from sbt-updates?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420

4 Answers4

14

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

enter image description here

Now provide the list of tasks separated by space in Tasks input box:

enter image description here

Nader Ghanbari
  • 4,120
  • 1
  • 23
  • 26
  • 3
    Lets say I want to use the "run" command here. How do I specify the port number? – WarLord Mar 23 '16 at 08:46
  • 1
    Did you try putting the command with the parameters in single quotes or backticks? – Nader Ghanbari Jun 13 '16 at 16:18
  • 2
    @nader-hadji-ghanbari, putting the SBT Task and its parameters in double quotes ("") was enough to get this working as a configuration, e.g. "test-only my.package.TestClassName" ;-D – Big Rich Jul 11 '16 at 15:58
8

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.

enter image description here

It does require a local installation of SBT.

Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • IntelliJ 2017.1.1 CE here, the method does not work as SBT is not found. Are you sure you had not sbt already installed system wide? – Ameba Spugnosa Apr 21 '17 at 13:00
  • I did install sbt locally as said in "It does require a local installation of SBT." (the last sentence). I think you could however use the built-in sbt in 2017.1.1. Haven't checked that out tough. – Jacek Laskowski Apr 21 '17 at 13:14
2

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/

František Hartman
  • 14,436
  • 2
  • 40
  • 60
-3

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 "$@"
Bas Peeters
  • 3,269
  • 4
  • 33
  • 49
sarit
  • 1