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
Related
I use SBT to include dependencies in my project, but I couldn't find the reason why some dependencies are ignored randomly. Even if they exist in .ivy2/cache directory, I tried to delete the content of it and retry but I still have the same problem.
The version of my SBT is 0.13.15 here is an example:
import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import ScalateKeys._
val ScalatraVersion = "2.4.1"
ScalatraPlugin.scalatraSettings
scalateSettings
organization := "com.*****"
name := "****"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.10.5"
val sparkVersion = "1.6.0"
resolvers += Classpaths.typesafeReleases
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.2.11",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
)
libraryDependencies += "org.apache.spark" %% "spark-core" % sparkVersion
libraryDependencies += "org.apache.spark" %% "spark-sql" % sparkVersion
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.2.14"
scalateTemplateConfig in Compile := {
val base = (sourceDirectory in Compile).value
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq(
Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
), /* add extra bindings here */
Some("templates")
)
)
}
enablePlugins(JettyPlugin)
In my example, sometimes the scalatra jsonis ignored and when I retried to create a new project the sparkdependencies was ignored
I finally found the solution of my issues, my project had to be converted to eclipse project through SBT with sbt eclipse command.
Initially the Scalatra project was created via SBT with this command:
sbt new scalatra/scalatra-sbt.g8
The trick is to eclipsify the project before beginning to import dependencies.
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 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?
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