I used to use:
"org.scalacheck" %% "scalacheck" % "1.10.1" % "test" withSources() withJavadoc(),
"org.specs2" %% "specs2" % "1.14" % "test" withSources() withJavadoc(),
Which worked fine, then I upgraded my dependencies to what I think are the latest:
"org.scalacheck" %% "scalacheck" % "1.12.1" % "test" withSources() withJavadoc(),
"org.specs2" %% "specs2-core" % "2.4.15" % "test" withSources() withJavadoc(),
Which should be correct according to http://etorreborre.github.io/specs2/
But now ScalaCheck is not being recognised as a member of org.specs2
[error] /Users/me/src/aFile.scala:7: object ScalaCheck is not a member of package org.specs2
[error] import org.specs2.ScalaCheck
[error] ^
I've done sbt clean and removed by ivy cache rm -r ~/.ivy2/cache
You need to add the specs2-scalacheck module to your build.
The documentation is wrong, you need to add multiple SBT lines to the build file, in particular add one according to Erics answer.
Also do NOT add the following, it causes a bunch of other errors
"org.specs2" %% "specs2" % "2.4.15" % "test" withSources() withJavadoc(),
Related
I upgraded my test dependencies for my play project and now I get this problem:
object scalacheck is not a member of package org.scalatestplus
[error] import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
These are my test dependencies:
"org.scalatest" %% "scalatest" % "3.2.3" % Test,
"org.scalamock" %% "scalamock" % "4.2.0" % "test",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.1" % "test",
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % "test, it",
Do I have some incompatible versioning going on here?
You don't have the right dependency:
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0"
Since you are using scalatest version 3.2.3, you should use scalacheck version 3.2.3.X, for compatability.
Here is its maven location, and this is its github repo.
Scala 2.13 Code run at Scastie.
Scala 2.12 Code run at Scastie.
I am trying to set up IntelliJ IDEA with sbt for a Scala project. The external dependencies are specified in my build.sbt and also listed inside the IDE, as can be seen in the screenshot. However, I still get compiler errors that saying the respective symbol cannot be resolved. Can anyone point me into the right direction?
Contents of my build.sbt:
lazy val midas = (project in file("."))
.settings(
name := "test",
mainClass in assembly := Some("core.Service"),
assemblyJarName in assembly := "test.jar",
test in assembly := {},
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "1.7.25",
"com.typesafe.akka" %% "akka-actor" % "2.5.13",
"com.typesafe.akka" %% "akka-slf4j" % "2.5.13",
"com.typesafe.akka" %% "akka-remote" % "2.5.13",
"org.scala-lang.modules" %% "scala-xml" % "1.1.0",
"com.typesafe.play" %% "play-json" % "2.6.9",
"com.typesafe.slick" %% "slick" % "3.2.3",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"ch.qos.logback" % "logback-core" % "1.2.3",
"com.mchange" % "c3p0" % "0.9.5.2",
"joda-time" % "joda-time" % "2.10",
"org.joda" % "joda-convert" % "2.0.1",
"net.sourceforge.jtds" % "jtds" % "1.3.1"
)
)
Still the dependencies for both, akka and joda-time cannot be resolved inside the IDE. The sbt compile from the command line works fine however.
joda-convert does not include org.joda.time.DateTime - you need "joda-time" % "joda-time" % "2.9.4" or so.
Once you have added this (and fixed your missing Akka import, maybe "com.typesafe.akka" %% "akka-actor" % "2.4.17"), you need to refresh the sbt project.
I press Shift, Shift to bring up "Search Everywhere" and type "sbt". Choose sbt under Tool Windows, then click "Refresh all sbt projects" (blue reload icon) in the sbt window. I close this window because it is not usually useful.
Hope that helps.
Is it possible to change the order of imports in sbt for scala compilation?
I have two unmanaged dependencies in the ./lib/ folder and the rest are managed dependencies in the sbt file:
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "1.7.10",
"org.slf4j" % "slf4j-simple" % "1.7.10",
"org.slf4j" % "slf4j-log4j12" % "1.7.10",
"com.typesafe" % "config" % "1.0.2",
"edu.washington.cs.knowitall.taggers" %% "taggers-core" % "0.4",
"com.rockymadden.stringmetric" % "stringmetric-core" % "0.25.3",
"org.apache.solr" % "solr-solrj" % "4.3.1",
"com.twitter" %% "util-collection" % "6.3.6",
"org.scalaj" %% "scalaj-http" % "0.3.10",
"commons-logging" % "commons-logging" % "1.2"
)
In Eclipse I can run my program, because I can change the order of imports in the java build path (I put unmanaged dependencies at the end).
However when I want to run it from the terminal:
sbt "run-main de.questionParser.Test"
I get the following error
[error] Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.Lists.reverse(Ljava/util/List;)Ljava/util/List;
So the final question is:
Is it possible to change the order of imports in sbt for scala compilation so that managed dependencies are included before unmanaged dependencies?
I'm using Typesafe Activator's last version (1.2.8 with Scala 2.11.x).
When I add a dependency "org.apache.httpcomponents" %% "httpclient" % "4.4-alpha1" to my project in build.sbt, something like this:
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.4",
"com.typesafe.akka" %% "akka-testkit" % "2.3.4",
"org.scalatest" %% "scalatest" % "2.1.6" % "test",
"junit" % "junit" % "4.11" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test",
"org.apache.httpcomponents" %% "httpclient" % "4.4-alpha1" // my added dependency
)
... and try to update the project ( in activator's cli ) I get an error:
[error] (*:update) sbt.ResolveException: unresolved dependency: org.apache.httpcomponents#httpclient_2.11;4.4-alpha1: not found
I know scala's version aren't binary compatible, but I try to get a pure-java library org.apache.httpcomponent#httpclient! Why does activator add "_2.11" at the end of artifactId and make wrong urls...? How to resolve it?
Change the first %% to a single %. The double character version is for fetching cross-built libraries, and yours isn't.
I've a problem building a module into a project with sbt 0.13.5 and scala 2.9.3, I have the dependency defined to
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.2.3" % "provided"
and even when the scalaVersion is explicitly set, throws this error:
[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/me/Code/project/}module:
[error] com.fasterxml.jackson.module:jackson-module-scala _2.9.2, _2.9.3
This is a provided dependency, that works on other module of the same project with the same resolvers and the same explicit scala version, the only difference there is in the additional dependencies, failing project has
"bouncycastle" % "bcprov-jdk16" % "140" % "provided",
"com.jolbox" % "bonecp" % "0.7.1.RELEASE" % "provided",
"mysql" % "mysql-connector-java" % "5.1.18" % "provided",
"org.liquibase" % "liquibase-core" % "3.0.5" % "provided",
"org.jdbi" % "jdbi" % "2.51" % "provided",
"javax.mail" % "mail" % "1.4" % "provided",
"com.twitter" % "finagle-redis" % "6.6.2" % "provided",
"com.twitter" % "finatra" % "1.3.9" % "provided"
Any idea on how to fix this? It appeared when updated to sbt 0.13, in 0.12 works ok.
Ok, I see what the problem is, finatra 1.3.9 is compiled with scala 2.9.2 and there's a dependency on fasterxml, Tried to fix by cross version mapping but it's a nighmare of dependencies, so, upgrading all dependencies to 2.10 is working so far.