I'm using this build.sbt
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
routesGenerator := InjectedRoutesGenerator
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-slick" % "2.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"com.h2database" % "h2" % "1.4.187",
"mysql" % "mysql-connector-java" % "5.1.34",
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0" % "test",
specs2 % Test
)
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "2.1.0",
"com.github.tototoshi" %% "slick-joda-mapper" % "1.2.0",
"joda-time" % "joda-time" % "2.7",
"org.joda" % "joda-convert" % "1.7"
)
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
fork in run := true
and the following errors happens:
missing or invalid dependency detected while loading class file
'JodaSetParameter.class'.
What am I missing? Should I be using a different version of joda?
Related
encounter a very strange problem.
I'm trying to use reactivemongo. And after update build.sbt
I can see that the jar is in the external library. However the compilation failed because not found object reactivemongo.
my build.sbt is:
hereenter code herelazy val commonSettings = Seq(
hereorganization := "emmettng.com",
hereversion := "0.0.1",
scalaVersion := "2.11.8"
)
hereresolvers += "Typesafe Repo" at"http://repo.typesafe.com/typesafe/releases/"
resolvers += "Typesafe repository releases" at"http://repo.typesafe.com/typesafe/releases/"`
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.11.8",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.4",
``"org.scalatest" %% "scalatest" % "3.0.0" % "test",
"com.typesafe.play" %% "play-json" % "2.4.0-M3",
"org.scalaz" %% "scalaz-core" % "7.2.5",
"junit" % "junit" % "4.10" % "test",
"org.reactivemongo" %% "reactivemongo" % "0.11.14"
)
I'm using this template to develop a microservice:
http://www.typesafe.com/activator/template/activator-service-container-tutorial
My sbt file is like this:
import sbt._
import Keys._
name := "activator-service-container-tutorial"
version := "1.0.1"
scalaVersion := "2.11.6"
crossScalaVersions := Seq("2.10.5", "2.11.6")
resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"
libraryDependencies ++= {
val containerVersion = "1.0.1"
val configVersion = "1.2.1"
val akkaVersion = "2.3.9"
val liftVersion = "2.6.2"
val sprayVersion = "1.3.3"
Seq(
"com.github.vonnagy" %% "service-container" % containerVersion,
"com.github.vonnagy" %% "service-container-metrics-reporting" % containerVersion,
"com.typesafe" % "config" % configVersion,
"com.typesafe.akka" %% "akka-actor" % akkaVersion exclude ("org.scala-lang" , "scala-library"),
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion exclude ("org.slf4j", "slf4j-api") exclude ("org.scala-lang" , "scala-library"),
"ch.qos.logback" % "logback-classic" % "1.1.3",
"io.spray" %% "spray-can" % sprayVersion,
"io.spray" %% "spray-routing" % sprayVersion,
"net.liftweb" %% "lift-json" % liftVersion,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test",
"io.spray" %% "spray-testkit" % sprayVersion % "test",
"junit" % "junit" % "4.12" % "test",
"org.scalaz.stream" %% "scalaz-stream" % "0.7a" % "test",
"org.specs2" %% "specs2-core" % "3.5" % "test",
"org.specs2" %% "specs2-mock" % "3.5" % "test",
"com.twitter" %% "finagle-http" % "6.25.0",
"com.twitter" %% "bijection-util" % "0.7.2"
)
}
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-Ywarn-dead-code",
"-language:_",
"-target:jvm-1.7",
"-encoding", "UTF-8"
)
crossPaths := false
parallelExecution in Test := false
assemblyJarName in assembly := "santo.jar"
mainClass in assembly := Some("Service")
The project compiles fine!
But when I run assembly, the terminal show me this:
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /path/.ivy2/cache/io.dropwizard.metrics/metrics-core/bundles/metrics-core-3.1.1.jar:com/codahale/metrics/ConsoleReporter$1.class
[error] /path/.ivy2/cache/com.codahale.metrics/metrics-core/bundles/metrics-core-3.0.1.jar:com/codahale/metrics/ConsoleReporter$1.class
What options do I have to fix it?
Thanks
The issue as it seems transitive dependency of the dependency is resulting with two different versions of metrics-core. The best thing to do would be to used the right library dependency so that you end up with a single version of this library. Please use https://github.com/jrudolph/sbt-dependency-graph , if it is difficult to figure out dependencies.
If it is not possible to get to a single version then you would most likely to go down exclude route . I assume, this only work, if there is compatibility between the all required versions.
How can I tell SBT to not include JARs from SBT plugins in my project's build?
I've noticed that plugin JARs, such as graphSettings, sbt-git and the likes get packaged in my final build.
Additionally, even if I set a particular dependency as "provided", it still gets packaged in build.
Thank you all in advance.
My Build.scala file:
object DALBuild extends Build {
sbtPlugin := true
val akkaVersion = "2.2.3"
val sprayVersion = "1.2.1"
val scalatraVersion = "2.2.2"
lazy val dal = Project(
id = "dal",
base = file("."),
settings = Project.defaultSettings ++ SbtOneJar.oneJarSettings ++ Seq(
name := "DAL",
organization := "com.foo.bar",
version := "0.5.28-SNAPSHOT",
scalaVersion := "2.10.4",
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
mainClass in SbtOneJar.oneJar := Some("com.foo.bar.http.server.BootDAL"),
retrieveManaged := true,
parallelExecution in Test := false,
fork in run := false,
fork in Test := true,
javaOptions in run += "-Dlogback.configurationFile=logback-dev.xml",
javaOptions in Test += "-Dlogback.configurationFile=logback-test.xml",
javaOptions in run += "-DUssdDb.env=dev",
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases",
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/",
resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
resolvers += "spray repo" at "http://repo.spray.io",
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % akkaVersion,
libraryDependencies += "com.typesafe.slick" % "slick_2.10" % "1.0.0",
libraryDependencies += "net.sourceforge.jtds" % "jtds" % "1.2.4",
libraryDependencies += "org.apache.cxf" % "cxf-rt-frontend-jaxws" % "2.7.5" exclude("commons-logging", "commons-logging"),
libraryDependencies += "org.apache.cxf" % "cxf-rt-transports-http-hc" % "2.7.5" exclude("commons-logging", "commons-logging"),
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.13",
libraryDependencies += "org.apache.tomcat" % "tomcat-jdbc" % "7.0.30",
libraryDependencies += "net.sourceforge.expectj" % "expectj" % "2.0.1" exclude("commons-logging", "commons-logging"),
libraryDependencies += "commons-net" % "commons-net" % "3.2",
libraryDependencies += "commons-beanutils" % "commons-beanutils" % "1.9.1" exclude("commons-logging", "commons-logging"),
libraryDependencies += "commons-logging" % "commons-logging" % "1.1.1" % "provided",
libraryDependencies += "org.slf4j" % "jcl-over-slf4j" % "1.7.7",
libraryDependencies += "org.scalatra" %% "scalatra" % scalatraVersion,
libraryDependencies += "org.scalatra" %% "scalatra-swagger" % scalatraVersion exclude("org.slf4j", "slf4j-log4j12"),
libraryDependencies += "org.scalatra" %% "scalatra-scalate" % scalatraVersion,
libraryDependencies += "org.scalatra" %% "scalatra-json" % scalatraVersion,
libraryDependencies += "org.eclipse.jetty" % "jetty-webapp" % "9.0.2.v20130417",
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.2.4",
libraryDependencies += "org.json4s" %% "json4s-native" % "3.2.4",
libraryDependencies += "io.spray" % "spray-client" % sprayVersion,
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test",
libraryDependencies += "org.scalatra" %% "scalatra-scalatest" % scalatraVersion % "test",
libraryDependencies += "com.typesafe.akka" % "akka-testkit_2.10" % akkaVersion % "test",
testOptions += Setup(cl => cl.loadClass("org.slf4j.LoggerFactory").
getMethod("getLogger",cl.loadClass("java.lang.String")).
invoke(null,"ROOT"))
)
)
.settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*)
}
Looks like an issue with SbtOneJar - you may want to file an issue with them directly.
You might be able to change the settings- eg: mappings in oneJar[1] although your milage may vary. Alternatively, look for a library that supports provided [2].
[1] https://github.com/sbt/sbt-onejar/blob/master/src/main/scala/com/github/retronym/SbtOneJar.scala#L37
[2] https://github.com/sbt/sbt-assembly#-provided-configuration
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.
I have a Scalatra project with the following build.sbt
organization := "com.example"
name := "scalatra-project"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.9.1"
seq(webSettings :_*)
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % "2.0.1",
"org.scalatra" %% "scalatra-scalate" % "2.0.1",
"org.scalatra" %% "scalatra-specs" % "2.0.2",
"org.scala-tools.testing" %% "specs" % "1.6.9",
"org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "container",
"javax.servlet" % "servlet-api" % "2.5" % "provided",
"net.liftweb" %% "lift-json" % "2.4-SNAPSHOT",
"net.liftweb" %% "lift-mongodb" % "2.4-M5",
"net.liftweb" %% "lift-mongodb-record" % "2.4-M5"
)
resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
resolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"
resolvers += "Scala Tools Releases" at "http://scala-tools.org/repo-releases/"
resolvers += "Maven Repo" at "http://repo1.maven.org/maven2"
When I run sbt, I get the following error:
error: not found: value webSettings seq(webSettings :_*)
How can I fix this problem?
check the plugin settings as mentioned here https://github.com/siasia/xsbt-web-plugin