sbt gen-idea scala version error - scala

I receive the following error when running sbt gen-idea:
[error] {file:/home/jem/projects/app/}default-0df603/*:
update-classifiers: Version specified for dependency
org.scala-lang#scalap;2.10.0 differs from Scala version in project (2.10.1).
Despite this the idea files are still created and seem to work. But I worry that they may be incomplete somehow.
Here is my build.sbt:
import com.typesafe.startscript.StartScriptPlugin
organization := "com.github.synesso"
name := "app"
version := "0.1"
scalaVersion := "2.10.1"
seq(webSettings :_*)
classpathTypes ~= (_ + "orbit")
libraryDependencies ++= Seq(
"org.scalatra" % "scalatra_2.10" % "2.2.1",
"org.scalatra" % "scalatra-scalate_2.10" % "2.2.1",
"org.scalatra" % "scalatra-json_2.10" % "2.2.1",
"org.eclipse.jetty" % "jetty-server" % "9.0.1.v20130408",
"org.eclipse.jetty" % "jetty-server" % "9.0.1.v20130408" % "container",
"org.eclipse.jetty" % "jetty-webapp" % "9.0.1.v20130408",
"org.eclipse.jetty" % "jetty-webapp" % "9.0.1.v20130408" % "container",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container,compile",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,compile" artifacts Artifact("javax.servlet", "jar", "jar"),
"org.json4s" % "json4s-jackson_2.10" % "3.2.4",
"org.slf4j" % "slf4j-simple" % "1.7.5",
"ch.qos.logback" % "logback-classic" % "1.0.11" % "runtime",
"com.google.api-client" % "google-api-client" % "1.14.1-beta",
"com.google.apis" % "google-api-services-plus" % "v1-rev62-1.14.1-beta",
"com.google.apis" % "google-api-services-oauth2" % "v1-rev33-1.14.1-beta",
"com.google.http-client" % "google-http-client-jackson2" % "1.14.1-beta"
)
resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/"
seq(StartScriptPlugin.startScriptForClassesSettings: _*)
I've tried mucking around with different versions of scala and the dependencies, but to no avail. What is going on here? Do I need to fix it? If so, how?

This is controlled by the checkExplicit value of the ivyScala setting. You can disable it with:
ivyScala ~= { (is: Option[IvyScala]) =>
for(i <- is) yield
i.copy(checkExplicit = false)
}
I'm surprised that is an error, since I'd normally expect it to be a warning. Also, this check is no longer on by default in 0.13.

Related

PlaySpecification not found in Play 2.6.3

I've imported Specs2 and everything looks good but some things that are not imported, among them the PlaySpecification trait.
I've tried to reload in sbt, to invalidate caches in Intellij ... But this trait is missing!
My built.sbt
name := """web2"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.12.2"
lazy val root = (project in file(".")).enablePlugins(PlayScala, LauncherJarPlugin)
pipelineStages := Seq(digest)
libraryDependencies ++= Seq(
evolutions,
jdbc,
ehcache,
ws,
"com.softwaremill.macwire" %% "macros" % "2.3.0" % "provided",
"org.postgresql" % "postgresql" % "42.1.1",
"org.scalikejdbc" %% "scalikejdbc" % "3.0.0",
"org.scalikejdbc" %% "scalikejdbc-config" % "3.0.0",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"de.svenkubiak" % "jBCrypt" % "0.4.1",
//"org.scalatestplus.play" %% "scalatestplus-play" % "3.0.+" % "test",
"org.mockito" % "mockito-core" % "2.7.22" % "test",
"org.specs2" %% "specs2-core" % "3.9.+" % "test"
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
plugins.sbt
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.2")
According to the documentation, replace "org.specs2" %% "specs2-core" % "3.9.+" % "test" with specs2 % Test in your dependencies:
libraryDependencies ++= Seq(
evolutions,
jdbc,
ehcache,
...
"org.mockito" % "mockito-core" % "2.7.22" % "test",
specs2 % Test
)

Slick codegen NoSuchMethodError

I have been trying to get slick's schema code generation to work. This is the method I'm using to run slicks code generator and the result that I'm getting.
scala>slick.codegen.SourceCodeGenerator.main(Array("slick.driver.MySQLDriver","com.mysql.jdbc.Driver","jdbc:mysql://localhost/adivinate","/Users/roy/adivinate/survey2/app/database","database","root","root"))
java.lang.NoSuchMethodError: slick.driver.JdbcProfile$API.Database()Lslick/backend/DatabaseComponent$DatabaseFactoryDef;
at slick.codegen.SourceCodeGenerator$.run(SourceCodeGenerator.scala:65)
at slick.codegen.SourceCodeGenerator$.main(SourceCodeGenerator.scala:94)
... 42 elided
scala>
I think I am missing a dependency but I don't know how to find it.
Here is my build.sbt.
name := """adivinate"""
version := "0.0.1"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.8"
incOptions := incOptions.value.withNameHashing(true)
updateOptions := updateOptions.value.withCachedResolution(cachedResoluton = true)
libraryDependencies ++= {
val ngVersion="2.2.0"
Seq(
cache,
evolutions,
//angular2 dependencies
"org.webjars.npm" % "angular__common" % ngVersion,
"org.webjars.npm" % "angular__compiler" % ngVersion,
"org.webjars.npm" % "angular__core" % ngVersion,
"org.webjars.npm" % "angular__http" % ngVersion,
"org.webjars.npm" % "angular__forms" % ngVersion,
"org.webjars.npm" % "angular__router" % "3.2.0",
"org.webjars.npm" % "angular__platform-browser-dynamic" % ngVersion,
"org.webjars.npm" % "angular__platform-browser" % ngVersion,
"org.webjars.npm" % "systemjs" % "0.19.40",
"org.webjars.npm" % "rxjs" % "5.0.0-beta.12",
"org.webjars.npm" % "reflect-metadata" % "0.1.8",
"org.webjars.npm" % "zone.js" % "0.6.26",
"org.webjars.npm" % "core-js" % "2.4.1",
"org.webjars.npm" % "symbol-observable" % "1.0.1",
"org.webjars.npm" % "typescript" % "2.1.4",
//tslint dependency
"org.webjars.npm" % "tslint-eslint-rules" % "3.1.0",
"org.webjars.npm" % "tslint-microsoft-contrib" % "2.0.12",
// "org.webjars.npm" % "codelyzer" % "2.0.0-beta.1",
"org.webjars.npm" % "types__jasmine" % "2.2.26-alpha" % "test",
//test
// "org.webjars.npm" % "jasmine-core" % "2.4.1"
//database dependencies
"mysql" % "mysql-connector-java" % "5.1.30",
//"com.typesafe.slick" % "slick_2.11" % "3.1.1", //included in play-slick
"com.typesafe.play" %% "play-slick" % "2.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"com.typesafe.slick" %% "slick-codegen" % "3.0.0",
"org.scala-lang" % "scala-reflect" % "2.12.1"
)
}
dependencyOverrides += "org.webjars.npm" % "minimatch" % "3.0.0"
// use the webjars npm directory (target/web/node_modules ) for resolution of module imports of angular2/core etc
resolveFromWebjarsNodeModulesDir := true
// use the combined tslint and eslint rules plus ng2 lint rules
(rulesDirectories in tslint) := Some(List(
tslintEslintRulesDir.value,
ng2LintRulesDir.value
))
logLevel in tslint := Level.Debug
routesGenerator := InjectedRoutesGenerator
fork in run := true

sbt different libraryDependencies in test than in normal mode

Because of conflicting / transitive (elasticsearch / lucene / jackrabbit) dependencies i want to have different libraryDependencies in test than i have when normally running the app. I solved it with the setup below, but this requires running activator with -Dtest and this will prevent my app from running normally when i'm done testing. The other way around, i.e. running just activator, will run my app but will not run my test. So, not very convenient and i think this can be done much better (btw i'm very new to sbt/scala)
name := """example"""
version := "0.1"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
// fork in Test := true
javaOptions in Test += "-Dconfig.file=conf/application.test.conf"
javaOptions in Test += "-Dlogger.file=conf/test-logger.xml"
// run activator -Dtest
if (sys.props.contains("test")) {
Seq[Project.Setting[_]](
libraryDependencies ++= {
Seq(
javaJdbc,
javaEbean,
cache,
javaWs,
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "bootstrap" % "3.3.6",
"org.webjars" % "font-awesome" % "4.5.0",
"be.objectify" %% "deadbolt-java" % "2.3.3",
"org.apache.lucene" % "lucene-core" % "3.6.0",
"org.elasticsearch" % "elasticsearch" % "1.7.4" exclude("org.apache.lucene", "lucene-core"),
"javax.jcr" % "jcr" % "2.0",
"org.apache.jackrabbit" % "jackrabbit-core" % "2.11.2",
"org.apache.jackrabbit" % "jackrabbit-jcr2dav" % "2.11.2",
"org.apache.tika" % "tika-parsers" % "1.11",
"org.apache.tika" % "tika-core" % "1.11",
"commons-io" % "commons-io" % "2.4",
"com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test"
)
}
)
} else {
Seq[Project.Setting[_]](
libraryDependencies ++= {
Seq(
javaJdbc,
javaEbean,
cache,
javaWs,
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "bootstrap" % "3.3.6",
"org.webjars" % "font-awesome" % "4.5.0",
"be.objectify" %% "deadbolt-java" % "2.3.3",
"org.elasticsearch" % "elasticsearch" % "1.7.4",
"javax.jcr" % "jcr" % "2.0",
"org.apache.jackrabbit" % "jackrabbit-core" % "2.11.2",
"org.apache.jackrabbit" % "jackrabbit-jcr2dav" % "2.11.2",
"org.apache.tika" % "tika-parsers" % "1.11",
"org.apache.tika" % "tika-core" % "1.11",
"commons-io" % "commons-io" % "2.4",
"com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test"
)
}
)
}
//.. our private nexus repo left out here
resolvers += "JBoss Repository" at "https://repository.jboss.org/nexus/content/repositories"
resolvers += "JBoss Third-Party Repository" at "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("Objectify Play Repository", url("http://deadbolt.ws/releases/"))(Resolver.ivyStylePatterns)
I don't have a setup where I can really test whether this works, but from how I understand sbt dependencies it should:
Dependencies can have a kind of scope called a configuration. Typically, this is used to define test only dependencies:
"com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test"
But you should also be able to define compile time and run time only dependencies using "compile" and "runtime" instead.
sbt prints me a warning if I use dependencies with different versions. The problem is, that this will use a different version of a dependency to compile it and then to run it with tests. So it will be run against a different version than it was compiled with. There are of course libraries, where this will work, especially, if you run with a newer version that what you use to compile.
If you really need to compile your application twice with different dependencies and use one build for running and one for testing, I fear, there won't be a solution without extending sbt or something like that.
You could try to make two modules, one with the main code and one for testing and then try to cross-build two different versions of the first module. Sbt can easily cross-build over multiple Scala versions, but I don't think it can do it out of the box for multiple versions of a library.
Thanks #dth, you put me on the right track. The settings below worked for me:
libraryDependencies ++= {
Seq(
javaJdbc,
javaEbean,
cache,
javaWs,
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "bootstrap" % "3.3.6",
"org.webjars" % "font-awesome" % "4.5.0",
"be.objectify" %% "deadbolt-java" % "2.3.3",
"org.apache.lucene" % "lucene-core" % "3.6.0" % "compile,test",
"org.elasticsearch" % "elasticsearch" % "1.7.4" % "compile,runtime",
"org.elasticsearch" % "elasticsearch" % "1.7.4" % "test" exclude("org.apache.lucene", "lucene-core"),
"javax.jcr" % "jcr" % "2.0",
"org.apache.jackrabbit" % "jackrabbit-core" % "2.11.2",
"org.apache.jackrabbit" % "jackrabbit-jcr2dav" % "2.11.2",
"org.apache.tika" % "tika-parsers" % "1.11",
"org.apache.tika" % "tika-core" % "1.11",
"commons-io" % "commons-io" % "2.4",
"com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test"
)
}

Why does IntelliJ IDEA debugger jump to wrong Scala version library?

I am using IntelliJ IDEA 13.1.2 with the Scala plugin version 0.36.431 on Windows 7 with sbt 0.13.1.
The following project definition build.sbt has no references to any Scala version other than 2.9.3.
import sbt._
import Keys._
import AssemblyKeys._
import NativePackagerKeys._
name := "simplews"
version := "0.1.0-SNAPSHOT"
val sparkVersion = "0.8.1-incubating"
scalaVersion := "2.9.3"
val akkaVersion = "2.0.5"
libraryDependencies ++= Seq(
"org.apache.spark" % "spark-core_2.9.3" % sparkVersion % "compile->default" withSources(),
"org.apache.spark" % "spark-examples_2.9.3" % sparkVersion % "compile->default" withSources(),
"org.apache.spark" % "spark-tools_2.9.3" % sparkVersion % "compile->default" withSources(),
"org.scalatest" % "scalatest_2.9.3" % "1.9.2" % "test" withSources(),
"org.apache.spark" % "spark-repl_2.9.3" % sparkVersion % "compile->default" withSources(),
"org.apache.kafka" % "kafka" % "0.7.2-spark",
"com.thenewmotion.akka" % "akka-rabbitmq_2.9.2" % "0.0.2" % "compile->default" withSources(),
"com.typesafe.akka" % "akka-actor" % akkaVersion % "compile->default" withSources(),
"com.typesafe.akka" % "akka-testkit" % akkaVersion % "compile->default" withSources(),
"com.rabbitmq" % "amqp-client" % "3.0.1" % "compile->default" withSources(),
"org.specs2" % "specs2_2.9.3" % "1.12.4.1" % "compile->default" withSources(),
"com.nebhale.jsonpath" % "jsonpath" % "1.2" % "compile->default" withSources(),
"org.mockito" % "mockito-all" % "1.8.5",
"junit" % "junit" % "4.11"
)
packagerSettings
packageArchetype.java_application
resolvers ++= Seq(
"Apache repo" at "https://repository.apache.org/content/repositories/releases",
"Cloudera repo" at "https://repository.cloudera.com/artifactory/repo/org/apache/kafka/kafka/0.7.2-spark/",
"akka rabbitmq" at "http://nexus.thenewmotion.com/content/repositories/releases-public",
"Local Repo" at Path.userHome.asFile.toURI.toURL + "/.m2/repository",
Resolver.mavenLocal
)
However as seen in the screenshot the debugger has jumped to scala 2.10.2. Note: the debugger is correctly going to 2.9.3 for some other debugging.
Here is project/plugins.sbt:
resolvers += "sbt-plugins" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-RC2")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
EDIT In order to reproduce it is necessary to do a mvn local install on one or two libraries that are not available in any public repo.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=c:\shared\kafka-0.7.2-spark.jar -DgroupId=org.apache.kafka -DartifactId=kafka -Dversion=0.7.2-spark -Dpackaging=jar
I had in any case not considered someone (om-nom-nom !) would attempt an exact reproduction - so had also omitted otherwise extraneous items like mergeStrategy and assemblyKeys.
A fully independent reproducible setup may be a bit in coming - I have been under rather quite heavy demands here.

IDEA and scalariform configuration - unresolved symbols even if scalariform works from command line

This question is partially related to sbt-scalariform plugin - can't resolve settings. I managed to run scalariform from command line as SBT task.
Now the problem is with IDEA. When I open my build.sbt, which looks like this:
import scalariform.formatter.preferences._
name := """scheduling-backend"""
version := "1.0"
scalaVersion := "2.10.2"
resolvers += "spray repo" at "http://repo.spray.io"
resolvers += "spray nightlies" at "http://nightlies.spray.io"
resolvers += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"
resolvers += "Neo4j Cypher DSL Repository" at "http://m2.neo4j.org/content/repositories/releases"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.0",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.0",
"com.typesafe.akka" %% "akka-testkit" % "2.3.0" % "test",
"com.typesafe.akka" %% "akka-persistence-experimental" % "2.3.0",
"io.spray" % "spray-can" % "1.3.0",
"io.spray" % "spray-routing" % "1.3.0",
"io.spray" % "spray-testkit" % "1.3.0" % "test",
"io.spray" %% "spray-json" % "1.2.5",
"ch.qos.logback" % "logback-classic" % "1.0.13",
"org.specs2" %% "specs2" % "1.14" % "test",
"org.springframework.scala" % "spring-scala" % "1.0.0.M2",
"org.springframework.data" % "spring-data-neo4j" % "3.0.0.RELEASE",
"org.springframework.data" % "spring-data-neo4j-rest" % "3.0.0.RELEASE",
"javax.validation" % "validation-api" % "1.1.0.Final",
"com.github.nscala-time" %% "nscala-time" % "0.8.0",
"org.neo4j" % "neo4j-kernel" % "2.0.1" % "test" classifier "tests",
"com.sun.jersey" % "jersey-core" % "1.9",
"org.mockito" % "mockito-all" % "1.9.5"
)
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-Ywarn-dead-code",
"-language:_",
"-target:jvm-1.7",
"-encoding", "UTF-8"
)
org.scalastyle.sbt.ScalastylePlugin.Settings
scalariformSettings
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(AlignParameters, true)
.setPreference(CompactControlReadability, true)
IDEA reports problems with my file.
I am getting Cannot resolve symbol scalariformSettings and Cannot resolve symbol ScalariformKeyseven if I everything works from terminal.
adding import com.typesafe.sbt.SbtScalariform._ to build.sbt seems to fix the error on 13.1.1 with scala plugin 0.33.403, but I have to admit it ignored the import at first and then randomly started to see it.