How to run sbt-assembly tasks from within IntelliJ

2019-02-06 10:35发布

问题:

Is it possible to run sbt-assembly from within IntelliJ IDEA?

Also I read in the doc that one could add task within the SBT Tool window. But what I see is that it only helps you view your project not task? I cannot add any tasks there. How does the Tool window work exactly?

I have the last version of IntelliJ IDEA.

回答1:

This answer is now out-of-date. IntelliJ now allows you to create a run configuration for an SBT task. You create the Run Configuration by :

  • choosing "Edit configurations" from the "Run" menu (or the toolbar popup)
  • click the "+" button to add a configuration and select "SBT Task" as the type of configuration you want to make.
  • fill out the details such as the name of the task and the working directory if necessary

You can now run the task in the same way as any other run configuration; select it in the run configuration popup in the toolbar and click the run button (or if you're one of those keyboard-only people press shift-ctrl-r and select the task from the popup that appears)

official documentation here : https://www.jetbrains.com/help/idea/2016.2/run-debug-configuration-sbt-task.html



回答2:

You can find the SBT plugin useful for your needs. With it, you can execute any tasks or command available in your build so sbt-assembly ones should work, too.

The plugin gives you SBT Console in which you start a sbt shell as if you were running it on the command line. The plugin gives you a more IDEA-like environment to work with the interactive console.