Intellij 13 and importing an SBT project - scala

I just installed Intellij 13 and tried importing some basic SBT project. However I received the following error:
The error message tells that org.jetbrains#sbt-structure;latest.integration cannot be found.
I am using SBT 0.13 and everything (compiling, running and etc..) seems to work from the CLI. I have also followed the installation instructions of the idea-sbt plugin (https://github.com/mpeltonen/sbt-idea).
build.sbt that I am using:
name := "demo"
version := "1.0"
scalaVersion := "2.9.2"
project/plugins.sbt:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
Did anyone had this issue and managed to resolve it?
Thanks!

This was a known issue and is resolved in the latest version 0.26.327 (try to run 'Check for Updates...').
If the problem persists, it must be due to another issue but not dependency resolution. In that case you can resort to using the sbt-idea plugin. From a terminal inside your project directory execute sbt gen-idea, afterwards you should be able to use 'Open Project...' in IDEA.

Related

How to activate the sbt DockerPlugin in scala?

I have two scala projects, one is already defined to build its docker container through the sbt docker plugin. The other one I want to dockerify as well.
The working one has in its build.sbt the following lines relevant to the docker config:
organization := "com.namespace"
name := "dockerized-app"
version := sys.env.getOrElse("PIPELINE_VERSION", "0.1.0_local")
scalaVersion := "2.12.4"
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
packageName in Docker := packageName.value
dockerRepository := Some("our-docker.io:5001")
dockerExposedPorts := Seq(8080)
I thought that I could copy paste the relevant lines to the new project, change the name, and make it work.
Yet when I add the line to the about to be dockerified scala project:
enablePlugins(DockerPlugin)
I get the error:
Cannot resolve symbol DockerPlugin
I've looked through the prexisting projects libraryDependencies, yet it doesn't seem to be configured that way. In the the pre-configured project, IntellJ somehow knows the plugin, I can track that the DockerPlugin comes from com.typesafe.sbt.packager.docker. This made me assume that sbt comes shipped with it by default.
Yet apparently I have to activate it somehow.
Digging deeper I also tried adding this to my plugins.sbt to no avail:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")
How to activate DockerPlugin using sbt in scala?
In order to make it working properly you need to add the following line:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")
in your project/plugins.sbt file.
Then refresh your project and it should work.
For further information, please check the Sbt Native Packager documentation.

Intellij sbt sbt-native-packager and enablePlugins error

I have an sbt build that works when I run from the command line, but that Intellij does not like. My Intellij is running on Linux, its version is 14.1.4, my scala plugin is 1.5.2.
Intellij complains about my use of enablePlugins(JavaAppPackaging). The error is "Expression Type (DslEntry) must conform to Setting[_] in SBT file".
My project/build.properties file:
sbt.version=0.13.8
My project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")
And the first few lines of my build.sbt
enablePlugins(JavaAppPackaging)
organization := "org.bodhi"
name := "jar-patch"
version := "1.0"
The answer by #lifeGoGoGo on another thread Intellij IDEA and SBT syntax error works for me (on Ubuntu, setting the custom sbt-launcher.jar in global settings and project settings of IntelliJ IDEA - as sensibly answered by #Mustafa on this thread - wasn't enough, but then adding the "lazy val" tactic was enough). So for example, this worked for me in build.sbt (obviously you change your plugin-details to suit what you are doing, as this issue is caused by IntelliJ and not by the specific plugin you want to enable):
lazy val root = (project in file(".")).
enablePlugins(ScalaJSPlugin).
settings(
name := "Scala.js Tutorial",
scalaVersion := "2.11.7",
version := "1.0"
)
IntelliJ uses a bundled SBT launcher which might be a different version than what you are running in the command line.
Since you already know that command line SBT works, you may point IntelliJ to use the command line SBT instead of the bundled one.
Go to settings page for SBT at Settings -> Build, Execution, Deployment -> Build Tools -> SBT.
In the launcher section, choose Custom and point to the SBT launcher installed in the OS. In Ubuntu, the default location is /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar
#karol: I had the same problem. I solved by choosing again at the moment of opening the project /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar in
"Import Project from SBT" -> Global SBT settings.
The issue is due to how IntelliJ IDEA marks syntax errors, which may mark valid code red. This particular error will be fixed soon.

Intellij doesn't seem actually run `sbt update` for modified dependencies

I recently updated a personal scala library that I have published to my local maven repo. In another project which uses this library, intellij refuses to acknowledge that this new library exists. In fact, it seems to be disregarding the contents of the build.sbt file altogether. Below is my current build.sbt file, with the updated dependency package (org.mechko.data).
name := "algorithms"
organization := "org.mechko"
version := "1.0"
scalaVersion := "2.10.4"
publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
libraryDependencies += "org.mechko" % "data_2.10" % "1.0.1" //updated dependency
It seems that running sbt update and sbt run in the terminal delivers the desired result using my updated library, so the problem is entirely with intellij. I have tried restarting intellij, and also invalidating the cache. I even tried putting incoherent garbage in my sbt file. Nothing evokes a response when I click refresh project. Any idea what might be the issue?
Thanks
My ultimate solution had three parts:
Uninstall and reinstall the scala plugin for intellij
Run sbt clean from the terminal
Delete the .idea folder in the project root and reimport the project
I tried combinations of these steps, but only when I did all three did Intellij agree to actually run the updates.

IntelliJ 13 with SBT plugin does not recognize Scalding dependency

I am trying to add Scalding 2.10 as a managed dependency via build.sbt like so:
name := "ss"
version := "1.0"
libraryDependencies += "com.twitter" % "scalding_2.10" % "0.10.0"
IntelliJ downloads the jar and adds it as an external library (see screen below) but fails to resolve the com.twitter namespace.
I have tried both invalidating the IntelliJ cache and generating project files via sbt gen-idea but neither solutions have worked. Any ideas would be greatly appreciated.
The scalding jar file scalding_2.10 has no code in it to compile against. Its just 300 Bytes in size.
The correct dependency I feel should be
libraryDependencies += "com.twitter" % "scalding-core_2.10" % "0.11.1"
As the comment suggest try rm-ing your ivy2 cache, and try sbt gen-idea. If that doesn't work, other things to check:
makes sure you have indeed got the scala plugin installed.
Most likely you're java SDK is not set or pointing somewhere wrong; right click the project dir, click "Open Module Settings", go to SDK and make sure the path is correctly set to the jdk otherwise syntax highlighting will likely break.
To test your deps have been properly pulled in from tinternet, try sbt compile; if it compiles then you should indeed have downloaded the dependency properly.

Typesafe Activator compilation error

I'm using Typesafe Activator on Ubuntu 13.04. It was working, but when I create a new project sometimes it doesn't do anything and sometimes it reports that the template is cloned (without downloading anything). When the project is created I get the following compile error:
Refreshing list of source files to watch for changes...
Loading project definition from
/home/myusername/activator-play-autosource-reactivemongo/project
Set current project to activator-play-autosource-reactivemongo (in
build file:/home/myusername/activator-play-autosource-reactivemongo/)
Applying State transformations com.typesafe.sbtrc.SetupSbtChild from
"""/home/myusername/.sbt/boot/scala-2.9.2/com.typesafe.sbtrc/sbt-rc-probe-0-12/1.0-28edcfb4984c8be5e556bad192b62551504aa23d/sbt-rc-props-1.0-28edcfb4984c8be5e556bad192b62551504aa23d.jar:/home/myusername/.sbt/boot/scala-2.9.2/com.typesafe.sbtrc/sbt-rc-probe-0-12/1.0-28edcfb4984c8be5e556bad192b62551504aa23d/sbt-rc-probe-0-12-1.0-28edcfb4984c8be5e556bad192b62551504aa23d.jar"""
java.lang.ClassNotFoundException: com.typesafe.sbtrc.SetupSbtChild$
Use 'last' for the full log.
Failed to reload source file list: sbt process never got in touch, so
unable to handle request WatchTransitiveSourcesRequest(true)
In project/build.properties change the sbt.version from 0.12.3 to 0.13.0 (or 0.12.4 alternatively).
I just had the same issue, for me this fixed it.
I just deleted all the activator generated files and it worked fine for me with following
In build.sbt:
scalaVersion := "2.10.4"
In project/plugin.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
Activator version: 1.1.3