How to use SBT with Intellij Idea - scala

I am using Scala version 2.10 and SBT version 0.13.8. To build a project I am currently executing the sbt commands through the Intellij terminal but I would like to know the use of SBT Tasks window on the right hand side of intellij idea window. Kindly have a look at the screenshot uploaded
How can I run SBT tasks (compile, run, package) in Intellij from SBT Tasks? Is my intellij configuration correct?

It looks like you're using an older version of IntelliJ IDEA. That the window displays "tasks" is probably a bug, because running tasks from this window is currently not supported by the Scala Plugin. I still recommend upgrading IDEA to version 2016.3, which also supports a newer version of the plugin.
Instead, you can run them from the terminal as you do now, or create a run configuration clicking on Run -> Edit Configurations. Then click the + button to add a new configuration and choose SBT Task from the list, and entering the tasks you would like to run.
Side note: When using sbt for your projects, the Scala version installed on the system doesn't matter. In fact, it doesn't even need to be installed.

Related

inetelliJ idea - sbt plugin conflicts with Standalone sbt

I want to setup a Spark-Scala-Sbt dev environment on Ubuntu
So i have installed SBT, Scala Seperately before installing IntelliJ.
But after installing intelliJ i have installed the sbt plugin for intelliJ as well.
Now how to avoid conflicts between the 2 sbt's which one to use and how to setup properly to avoid conflict.
Also wanted to know HOW .. the installed Scala & SBT is different from the scala & sbt plugin that comes with itelliJ IDEA
The standalone sbt plugin is obsolete with IntelliJ Scala Plugin 2017.1, which includes an integrated sbt shell and supports building through that shell.
To avoid any conflicts between different instances of sbt shells, it is best to have only one running at a time - either from the terminal or from IDEA. Other than that you don't need any special setup.

ScalaTest option not available under "Run As" Menu in Scala IDE

I have recently switched computers and am trying to get ScalaTest to run in my ScalaIDE again.
When I right click on the file in the project explorer, or when I right click on the code in the editor, I can see the "Run As" option in the drop down menu, but the only option available is "Run Configurations."
I can create my own run configuration manually, and run the test just fine, and then have a run configuration that I can run from the Run icon in the toolbar, but I don't what to have to create one of these for each tests.
Here is what I have so far, and would be grateful if anybody could provide any additional ideas:
Verified that ScalaTest library is being added to the project via SBT.
Verified that the Plugin is indeed installed (and re-installed multiple times)
Verified that I can run the tests from command line, in addition to my manually configuration in Eclipse.
Ran eclipse with -clean command
Tried running eclipse as root, and re-installing plugin while running as root.
Tried giving all access to all directories in Eclipse.app directory
Compared my setup to a co-worker who also recently set up his computer with the same image, and should have very similar versions of Scala, ScalaIDE, and ScalaTest plugin.
Created a new workspace and reimported my projects into that workspace.
cleared ivy cache and rebuild eclipse project.
My system:
OSX: Yosemite 10.10.5
Scala: 2.11.6
JRE: 1.8.0
ScalaIDE: 4.1.1-vfinal-20150727-1320-Typesafe
ScalaTest Plugin: 2.9.3.v-4-2_11-201509031342-a29ebef
This morning there was an updated ScalaTest Plugin:
2.9.3.v-4-2_11-201509221346-a29ebef
After updating, everything works fine!
I'll leave this here, as I'm thinking that the steps I took in my question seem to encompass most of the recommended steps that I have seen from various other StackOverflow errors.

Running ApsctJ in Intellij IDEA with Scala

I am using Intellij IDEA Community Edition 14.0.3 for Scala development. I am having AspectJ in my application. I am using sbt-aspect v0.10.1.
I am able to run everything fine when I run the application from SBT console. However, when I use run from the intellij menu, it is not invoking the aspect.
Because of this, I am not able to run in Debug Mode. How can I make it work with intellij ?
I have the same issue.
My workaround is:
Open project Run/Debug configuration on IntelliJ IDEA
In the VM Options field type: -javaagent:path/to/aspectjweaver.jar
path/to/aspectjweaver.jar in my case is C:\Users\aelkin\.ivy2\cache\org.aspectj\aspectjweaver\jars\aspectjweaver-1.8.13.jar
Actually I do not use Scala in IntelliJ IDEA, but Java. Anyway, a quick web search led me to the SBT Community Plugins page which lists these links:
Plugins for IDEs
IntelliJ IDEA
sbt Plugin to generate IDEA project configuration: https://github.com/mpeltonen/sbt-idea
IDEA Plugin to embed an sbt Console into the IDE: https://github.com/orfjackal/idea-sbt-plugin
At the time of writing this GitHub is down for database maintenance, so I cannot check on the projects mentioned there, but in 15 minutes or you should be able to navigate there by yourself and see if the repos actually contain something useful for you.

Scala build process

First some context:
My aim is to use scala alongside a testing environment, preferably in an ide.
At first I installed scala (v. 2.10.1) and sbt and it worked. I used emacs and a shell.
Then I wanted to use eclipse and installed the sbt plugin. But when I tried the FlatSpec example of the scalatest website together with the scalatest lib, it did compile but 0/0 tests did run.
In intellij I tried the same example but although I gave my sdk location, the collection package wasn't found.
My problem:
I don't understand what I have to tell my ide or what I have to write (maybe files for maven or make etc.) or where I can learn all that.
My question:
What has the ide to know if I want to run a scala project?
- location of sdk, jdk, sbt, my_project, ...
- versions of scala, java etc.
What else must it know?
IntelliJ has build in support for sbt projects. My work flow is the following :
Create a project (in the shell) using sbt. Basically you have to create a build.sbt and the necessary directory structure
`src/main/scala`
`src/main/resources`
`src/test/`
The in IntelliJ just do Open -> select build.sbt.
Also check auto-import checkbox.
Everything should work after this.
NOTE: You may have to install the Scala and sbt plugin for the above to work.

IntelliJ IDEA 12 versus sbt 0.13

I am updating a couple of projects to sbt 0.13. I am using IntelliJ IDEA 12 (not interested in EAP 13 at this moment). I am using the sbt plugin by orfjackal. By default it uses an sbt-launch.jar bundled with IDEA. At least the settings claim that. That has version 0.12 and cannot be launched now because of some JLine incompatibility.
If I go to Settings -> Project Settings -> SBT -> IDE Settings, and specify the 0.13 launcher as custom jar, it works while IntelliJ is open. But the settings are lost when I quit and restart IntelliJ.
So my new idea is to try to replace the bundled sbt-launch.jar. If I open the app bundle (OS X) and search for that name, nothing shows up.
Where is the bundled sbt-launch.jar and how can I swap it?
I believe that SBT jar is located inside your configuration directory. Usually it is something like ~/.IntelliJIdea12, so simple search in this directory gave ~/.IntelliJIdea12/system/sbt/sbt-launch.jar. Try replacing it.
BTW, there is currently a new official SBT plugin being developed by JetBrains. It really is great and simplified SBT usage inside IDEA a lot (esp. dependency management), but it does not have embedded console yet (it will, soon). You can try it out even in 12.X IDEA.