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.
Related
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.
I created a new project using Play Scala and Eclipse. Added Squeryl dependency and see that it's been pulled during compile time. Confirmed it's present in .ivy2/cache/org.squeryl directory but eclipse project is not able to pull it up and causing compilation for import.
build.sbt
name := """registration"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws,
"org.squeryl" % "squeryl_2.10" % "0.9.6-RC2"
)
It looks like squeryl doesn't have a binary readily available for Scala 2.11 yet according to http://www.squeryl.org/getting-started.html
So if you want to use a pre-compiled version of this library you must change your scala version to 2.10.4.
All versions of squeryl available can be found at: http://mvnrepository.com/artifact/org.squeryl
I had a similar case using eclipse.
Select Project --> Clean to clean your workspace and build it again if you have not checked "Build Automatically".
If its still not visible please refresh the package explorer (or just the 'Referenced Library') with F5.
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.
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.
I am trying a very simple sbt example; when I compile it with sbt, and always get the following error:
org.scala-sbt#sbt_2.9.1;0.12.3: not found
I found a build.properties file under project folder, where I could change the 0.12.3 part; for example, after I changed it to 0.11.3, it will succeed until another inompatible issue; However, I want to know how to change sbt_2.9.1 to, say, sbt_2.9.2; I don't find a configuration file, and even I update the sbt to the latest version 0.12.3, still no luck.
my build.sbt file:
organization := "com.typesafe.slick"
name := "slick-examples"
version := "1.0.1-RC1"
scalaVersion := "2.10.1"
scalacOptions += "-deprecation"
anyone please help me.
The Scala version sbt is using internally and the one used for your project are totally independent. Which sbt launcher are you using? Make sure you are using an sbt.version property that works for your sbt launcher.
Again, no need to configure the Scala version for your project at that level. Write a build.sbt file and set scalaVersion to, e.g. 2.10.1 (assuming you use sbt 0.12.x): scalaVersion := 2.10.1