How to set envVars for multiproject? - scala

I have sbt multi projects and try to set the envVars in the build.sbt for subprojects as following:
envVars in Test := Map("KAFKA_SERVER" -> "localhost:9092")
the test abort with following message:
[info] java.util.NoSuchElementException: None.get
[info] at scala.None$.get(Option.scala:349)
[info] at scala.None$.get(Option.scala:347)
[info] at io.khinkali.auth.AppSpec.<init>(AppSpec.scala:23)
[info] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
In the test file, I tried to get the value as following:
sys.env.get("KAFKA_SERVER").get
Intellj provides the set the environment variable as following:
How to set an environment variable in sbt for subprojects also?
Update
The root build.sbt looks as following:
name := "bary"
scalacOptions += "-Ypartial-unification"
scalacOptions += "-feature"
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
val Cats = "1.0.0"
val Shiro = "1.4.0"
val Logback = "1.2.3"
val CatsEffect = "0.5"
val Kafka = "1.0.0"
val Bean = "1.9.3"
val Circe = "0.9.0-M3"
val Log4j = "1.7.25"
val ScalaCheck = "1.13.4"
val Scalactic = "3.0.4"
val Scalatest = "3.0.4"
val JavaJwt = "3.3.0"
val Simulacrum = "0.11.0"
val Http4s = "0.18.0-M7"
lazy val commonSettings = Seq(
organization := "io.khinkali",
version := "0.1.0-SNAPSHOT",
scalaVersion := "2.12.4",
envVars in Test := Map("KAFKA_SERVER" -> "localhost:9092"),
fork in Test := true,
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-simple" % Log4j,
"ch.qos.logback" % "logback-core" % Logback,
"org.apache.shiro" % "shiro-all" % Shiro,
"org.typelevel" %% "cats-core" % Cats,
"org.typelevel" %% "cats-effect" % CatsEffect,
"org.apache.kafka" % "kafka-streams" % Kafka,
"org.apache.kafka" % "kafka-clients" % Kafka,
"commons-beanutils" % "commons-beanutils" % Bean,
"io.circe" %% "circe-core" % Circe,
"io.circe" %% "circe-generic" % Circe,
"io.circe" %% "circe-parser" % Circe,
"io.circe" %% "circe-literal" % Circe,
"com.github.mpilquist" %% "simulacrum" % Simulacrum,
"org.scalactic" %% "scalactic" % Scalactic,
"org.scalatest" %% "scalatest" % Scalatest % "test",
"org.scalacheck" %% "scalacheck" % ScalaCheck % "test",
),
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
),
fork in run := true,
)
lazy val root = (project in file("."))
.settings(commonSettings)
.settings(
name := "bary",
organization := "io.khinkali",
moduleName := "bary"
).
aggregate(
kafka_api,
auth_stream,
rest)
lazy val kafka_api = (project in file("kafka-api")).
settings(commonSettings).
settings(
name := "kafka-api",
moduleName := "kafka-api"
)
lazy val auth_stream = (project in file("auth-stream")).
settings(commonSettings).
settings(
name := "auth-stream",
moduleName := "auth-stream",
libraryDependencies ++= Seq(
"com.auth0" % "java-jwt" % JavaJwt,
)
).dependsOn(kafka_api)
lazy val rest = (project in file("rest")).
settings(commonSettings).
settings(
name := "rest",
moduleName := "rest",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-dsl" % Http4s,
"org.http4s" %% "http4s-blaze-server" % Http4s,
"org.http4s" %% "http4s-blaze-client" % Http4s,
"org.http4s" %% "http4s-circe" % Http4s,
)
).dependsOn(kafka_api, auth_stream)
I still got the exception.

Any setting you want to apply to a subproject can either be specified just for that subproject or in commonSettings, as shown in build.sbt below.
You did not show your multiproject definitions, so here is a short example. There are many ways of setting up these types of projects, and I am not going to elaborate on the possible ways; this is a complicated topic, and it has evolved a lot over the years, especially recently.
lazy val commonSettings = Seq(
envVars in Test := Map("KAFKA_SERVER" -> "localhost:9092"),
fork in Test := true, // required for envVars task to work
javacOptions ++= Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
"-source", "1.8",
"-target", "1.8",
"-g:vars"
),
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")),
version := "0.5.0"
)
lazy val demo = project
.settings(commonSettings:_*)
.settings(
name := "demo"
).dependsOn(root)
lazy val root = (project in file("root"))
.settings(commonSettings:_*)
.settings(
name := "root"
)
One more important fact: The environment setting for test will not be respected when run with the IntelliJ IDEA test runner. As a workaround, you can set environment variables in the Run/Debug Configurations -> Environment variables window. When you run sbt test, however, the environment variable specified in build.sbt will be set.
Normally, the only way to apply an environment variable to a process is to start the process with that environment variable. If you want SBT to run your program in an environment with a certain environment variable, it will need to be launched in a new environment. This is called forking.

Related

How to reference a project definition in a parent build.sbt file?

I'm playing around with the scala-forklift library and wanted to test an idea by modifying the code in the library and example project.
This is how the project is structured:
/build.sbt -> Contains definition of scala-forklift-slick project (including its dependencies) in the form of:
lazy val slickMigrationProject =
Project("scala-forklift-slick", file(...))
.dependsOn(...)
.settings(...)
...
/example/build.sbt -> References scala-forklift-slick via its Maven package.
My goal is to replace the scala-forklift-slick Maven package reference with a reference to the code in the parent directory, perhaps via .dependsOn(slickMigrationProject)?
Attempts:
According to the documentation:
Any .sbt files in foo, say foo/build.sbt, will be merged with the build definition for the entire build, but scoped to the hello-foo project.
But this does not seem to apply to lazy val values, as I can't access slickMigrationProject from the parent project directly.
I have been successful copying the entire contents of /example/build.sbt into /build.sbt and tweaking things a bit, but I was wondering if there was a better "one-liner" kind of solution instead.
Here is what my combined /build.sbt file looks like:
val repoKind = SettingKey[String]("repo-kind",
"Maven repository kind (\"snapshots\" or \"releases\")")
lazy val slickVersion = "3.3.3"
lazy val scala212 = "2.12.11"
lazy val scala213 = "2.13.1"
lazy val supportedScalaVersions = List(scala212, scala213)
lazy val coreDependencies = libraryDependencies ++= List(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"com.typesafe" % "config" % "1.3.2",
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.0.1.201506240215-r"
)
lazy val slickDependencies = List(
"com.typesafe.slick" %% "slick" % slickVersion,
"com.typesafe.slick" %% "slick-codegen" % slickVersion,
"io.github.nafg" %% "slick-migration-api" % "0.7.0",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.0.0"
)
lazy val slickDependenciesWithTests = slickDependencies ++ List(
"org.scalatest" %% "scalatest" % "3.1.0",
"com.lihaoyi" %% "ammonite-ops" % "2.0.4",
"commons-io" % "commons-io" % "2.6",
"com.typesafe.slick" %% "slick-hikaricp" % slickVersion,
"com.h2database" % "h2" % "1.4.200",
"org.xerial" % "sqlite-jdbc" % "3.8.11.2",// 3.30.1 crashes SQLiteCommandTests
"mysql" % "mysql-connector-java" % "5.1.38",
"org.postgresql" % "postgresql" % "42.2.9",
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.apache.derby" % "derby" % "10.14.2.0",
"ch.qos.logback" % "logback-classic" % "1.2.3"
).map(_ % "test")
lazy val commonSettings = Seq(
organization := "com.liyaos",
licenses := Seq("Apache 2.0" ->
url("https://github.com/lastland/scala-forklift/blob/master/LICENSE")),
homepage := Some(url("https://github.com/lastland/scala-forklift")),
scalaVersion := scala213,
scalacOptions += "-deprecation",
scalacOptions += "-feature",
resolvers += Resolver.jcenterRepo,
publishMavenStyle := true,
publishArtifact in Test := false,
repoKind := { if (version.value.trim.endsWith("SNAPSHOT")) "snapshots"
else "releases" },
publishTo := { repoKind.value match {
case "snapshots" => Some("snapshots" at
"https://oss.sonatype.org/content/repositories/snapshots")
case "releases" => Some("releases" at
"https://oss.sonatype.org/service/local/staging/deploy/maven2")
}},
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
pomExtra := (
<scm>
<url>git#github.com:lastland/scala-forklift.git</url>
<connection>scm:git:git#github.com:lastland/scala-forklift.git</connection>
</scm>
<developers>
<developer>
<id>lastland</id>
<name>Yao Li</name>
</developer>
</developers>))
// Derby is running is secured mode since version 10.12.1.1, so security manager must be disabled for tests
// https://stackoverflow.com/questions/48008343/sbt-test-does-not-work-for-spark-test
// https://issues.apache.org/jira/browse/DERBY-6648
Test / testOptions += Tests.Setup(() => System.setSecurityManager(null))
lazy val root = Project(
"scala-forklift", file(".")).settings(
crossScalaVersions := Nil,
publishArtifact := false).aggregate(
coreProject, slickMigrationProject, plainMigrationProject, gitToolProject, example)
lazy val coreProject = Project(
"scala-forklift-core", file("core")).settings(
commonSettings:_*).settings {Seq(
crossScalaVersions := supportedScalaVersions,
coreDependencies
)}
lazy val slickMigrationProject = Project(
"scala-forklift-slick", file("migrations/slick")).dependsOn(
coreProject).settings(commonSettings:_*).settings { Seq(
crossScalaVersions := supportedScalaVersions,
libraryDependencies ++= slickDependenciesWithTests
)}
lazy val plainMigrationProject = Project(
"scala-forklift-plain", file("migrations/plain")).dependsOn(
coreProject).settings(commonSettings:_*).settings(crossScalaVersions := supportedScalaVersions)
lazy val gitToolProject = Project(
"scala-forklift-git-tools", file("tools/git")).dependsOn(
coreProject).settings(commonSettings:_*).settings(crossScalaVersions := supportedScalaVersions)
///////////////////////////////////////////////
name := "forklift-slick-example"
addCommandAlias("mgm", "example/migration_manager/run")
addCommandAlias("mg", "example/migrations/run")
lazy val exampleCommonSettings = Seq(
organization := "com.liyaos",
version := "2.0",
scalaVersion := "2.13.1",
scalacOptions += "-deprecation",
scalacOptions += "-feature",
resolvers += Resolver.sonatypeRepo("snapshots"),
resolvers += Resolver.jcenterRepo,
)
lazy val loggingDependencies = List(
"org.slf4j" % "slf4j-nop" % "1.6.4" // <- disables logging
)
lazy val exampleSlickDependencies = List(
"com.typesafe.slick" %% "slick" % slickVersion
)
lazy val dbDependencies = List(
"com.typesafe.slick" %% "slick-hikaricp" % slickVersion
,"com.h2database" % "h2" % "1.4.200"
)
lazy val forkliftDependencies = List(
// "com.liyaos" %% "scala-forklift-slick" % forkliftVersion
)
lazy val appDependencies = dbDependencies ++ loggingDependencies
lazy val migrationsDependencies =
dbDependencies ++ forkliftDependencies ++ loggingDependencies
lazy val migrationManagerDependencies = dbDependencies ++ forkliftDependencies
lazy val example = Project("example", file("example")).aggregate(
app, migrations, migrationManager, generatedCode, tools).settings(
exampleCommonSettings:_*)
lazy val app = Project("app", file("example/app"))
.dependsOn(generatedCode)
.settings(exampleCommonSettings:_*)
.settings {libraryDependencies ++= appDependencies}
lazy val migrationManager = Project("migration_manager", file("example/migration_manager"))
.dependsOn(slickMigrationProject)
.settings(exampleCommonSettings:_*)
.settings {libraryDependencies ++= migrationManagerDependencies}
lazy val migrations = Project("migrations", file("example/migrations"))
.dependsOn(generatedCode, migrationManager, slickMigrationProject)
.settings(exampleCommonSettings:_*)
.settings {libraryDependencies ++= migrationsDependencies}
lazy val tools = Project("git-tools", file("example/tools/git"))
.dependsOn(slickMigrationProject, gitToolProject)
.settings(commonSettings:_*)
.settings {
libraryDependencies ++= forkliftDependencies ++ List(
// "com.liyaos" %% "scala-forklift-git-tools" % forkliftVersion,
"com.typesafe" % "config" % "1.3.0",
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.0.1.201506240215-r"
)
}
lazy val generatedCode = Project("generate_code", file("example/generated_code"))
.settings(exampleCommonSettings:_*)
.settings {libraryDependencies ++= exampleSlickDependencies}
Question:
Is there a simple way I can replace the scala-forklift-slick Maven package reference in /example/build.sbt with a link to the existing scala-forklift-slick project definition in the parent directory's build.sbt so I can use .dependsOn(...) instead?
Or maybe it's better to do something like build scala-forklift-slick and use a local disk package resolver?
Luis Miguel Mejía Suárez's comment worked perfectly and was the easier approach.
In the context of this project, all I had to do was:
Append -SNAPSHOT to the version in /version.sbt (should not be needed normally but for this project I had to do this)
Run sbt publishLocal in the parent project.
After this, the example project (which already targets the -SNAPSHOT version) is able to pick up the locally built package.

Sbt 0.13 to 1.0 - What's the replacement for onLoad in Global for multiprojects?

I am trying to create a new project, this time with sbt 1.0.2 instead of 0.13.x which I used for quite some time now.
There I had a multi-project setup comparable to https://github.com/vmunier/akka-http-with-scalajs-example/blob/master/build.sbt
My problem now is that I always get [error] (projectname/compile:bgRun) No main class detected. when I try to run sbt run
Here is my current build.sbt file:
lazy val generalSettings = Seq(
name := "awesomeproject.tld",
version := "0.1",
scalaVersion := "2.12.3"
)
lazy val client = (project in file("modules/client"))
.settings(generalSettings: _*)
.settings(
name := "client",
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "scalatags" % "0.6.5",
"org.scala-js" %%% "scalajs-dom" % "0.9.2"
)
, scalaJSUseMainModuleInitializer := true
)
.enablePlugins(ScalaJSPlugin, ScalaJSWeb)
.dependsOn(sharedJS)
lazy val server = (project in file("modules/server"))
.settings(generalSettings: _*)
.settings(
name := "server",
scalaJSProjects := Seq(client),
pipelineStages in Assets := Seq(scalaJSPipeline),
// triggers scalaJSPipeline when using compile or continuous compilation
//compile in Compile := ((compile in Compile) dependsOn scalaJSPipeline).value,
WebKeys.packagePrefix in Assets := "public/",
//managedClasspath in Runtime += (packageBin in Assets).value,
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.4",
"com.typesafe.akka" %% "akka-testkit" % "2.5.4" % Test,
"com.typesafe.akka" %% "akka-stream" % "2.5.4",
"com.typesafe.akka" %% "akka-stream-testkit" % "2.5.4" % Test,
"com.typesafe.akka" %% "akka-http" % "10.0.10",
"com.typesafe.akka" %% "akka-http-testkit" % "10.0.10" % Test,
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.typesafe.scala-logging" %% "scala-logging" % "3.7.2",
"com.lihaoyi" %% "scalatags" % "0.6.5",
"com.vmunier" %% "scalajs-scripts" % "1.1.0"
)
, mainClass := Some("tld.awesomeproject.Main")
)
.dependsOn(sharedJVM)
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("modules/shared"))
.settings(generalSettings: _*)
.settings(
name := "shared"
)
lazy val sharedJS = shared.js
lazy val sharedJVM = shared.jvm
As you can see I tried to solve the problem with setting it explicitly with mainClass := Some("tld.awesomeproject.Main") in the subproject. I also tried to set a root project explicitly, make it dependOn the server but no luck.
I guess the real problem here is, that
onLoad in Global := (Command.command("project server", _: State)) compose (onLoad in Global) does not work in sbt 1.0.2 anymore.
I checked the Command class, but I am not wiser after. There simply is no more method that gives back a state.
Can anyone shed like on this? What I want is to run a server that sends some javascript to the client... that shouldn't be black magic, in fact everything worked like a charm in my 0.13. project.
This should work:
onLoad in Global ~= (_ andThen ("project server" :: _))
Reference: https://github.com/sbt/sbt/issues/1224#issuecomment-331840364

Can not create a multi project build

I am trying to create a Play application with a back end and a front end(using Scala.js). I separated the code into client and server folders.
For creating a Multi Project Build I looked at this http://www.scala-sbt.org/release/docs/Multi-Project.html and make my build.sbt like this:
name := """ScalaWeb"""
version := "1.0-SNAPSHOT"
lazy val commonSettings = Seq(
scalaVersion := "2.11.7",
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test
),
libraryDependencies ++= Seq(
"org.sorm-framework" % "sorm" % "0.3.19",
"org.scala-lang" % "scala-compiler" % scalaVersion.value force(),
"com.h2database" % "h2" % "1.3.148"
),
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
/*libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.12"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"*/
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases",
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator,
scalacOptions += "-Ylog-classpath",
// use this if you just want jawn's parser, and will implement your own facade
libraryDependencies += "org.spire-math" %% "jawn-parser" % "0.8.3",
// use this if you want jawn's parser and also jawn's ast
libraryDependencies += "org.spire-math" %% "jawn-ast" % "0.8.3",
//for reading Json libraries
libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.2.1"
)
lazy val server = (project in file("server")).settings(
commonSettings: _*
).enablePlugins(PlayScala)
lazy val client = (project in file("client")).settings(
commonSettings: _*
).enablePlugins(PlayScala)
fork in run := true
So basically I placed all dependencies into commonSettings and the imported that into the client and server projects.
However, I am getting this error:
[error] (scalaweb/compile:backgroundRun) No main class detected.
Why is this occuring?
Have I set up my build.sbt incorrectly?
That's because your root project (scalaweb) doesn't have a main class.
You can either:
run server's run command by doing: server/run
aggregate client and server under root project
(http://www.scala-sbt.org/0.13/docs/Multi-Project.html#Aggregation)
This might do what you wish.

NoClassDefFoundError running tests in SBT with scoverage plugin

I have an SBT project with structure like here: https://orrsella.com/2014/09/24/integration-and-end-to-end-test-configurations-in-sbt-for-scala-java-projects/. It includes standard main and test directories and additionally it and e2e. There is also a task "test-all" which runs all tests. Everything works correctly unless I run e2e or test-all together with coverage plugin. I'm getting: java.lang.NoClassDefFoundError: scoverage/Invoker$
Using show it:dependencyClasspath and show e2e:dependencyClasspath, I can see that e2e classpath is missing scoverage plugin jars. Any idea what's wrong and how to solve it?
Build.sbt
import org.scalatra.sbt._
import sbt.Keys._
import sbt._
object MaAppBuild extends Build {
val Organization = "com.my-org"
val Name = "My App"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.11.6"
val AkkaVersion = "2.3.4"
val ScalatraVersion = "2.3.0"
lazy val project = Project(
"My-App",
file("."),
configurations = Configurations.default ++ Testing.configs,
settings = Defaults.coreDefaultSettings ++ ScalatraPlugin.scalatraSettings ++ Testing.settings ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
resolvers += "Akka Repo" at "http://repo.akka.io/repository",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % AkkaVersion,
"com.typesafe.akka" % "akka-testkit_2.11" % AkkaVersion % "test;it;e2e",
"net.databinder.dispatch" %% "dispatch-core" % "0.11.1",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"com.typesafe.akka" %% "akka-testkit" % AkkaVersion % "test;it;e2e",
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test;it;e2e",
"com.github.tomakehurst" % "wiremock" % "1.55" % "test;it;e2e",
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
"org.scalatra" %% "scalatra-json" % "2.4.0.RC1",
"org.json4s" %% "json4s-jackson" % "3.2.11",
"com.typesafe" % "config" % "1.2.1",
"org.json4s" %% "json4s-native" % "3.2.11",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts Artifact("javax.servlet", "jar", "jar")
)
)
)
}
Integration and e2e tests configuration:
import sbt.Keys._
import sbt._
object Testing {
val IntegrationTest = config("it").extend(Runtime)
val EndToEndTest = config("e2e").extend(Runtime)
val configs = Seq(IntegrationTest, EndToEndTest)
lazy val testAll = TaskKey[Unit]("test-all")
private lazy val itSettings =
inConfig(IntegrationTest)(Defaults.testSettings) ++
Seq(
fork in IntegrationTest := false,
parallelExecution in IntegrationTest := false,
scalaSource in IntegrationTest := baseDirectory.value / "src/it/scala",
resourceDirectory in IntegrationTest := baseDirectory.value / "src/test/resources")
private lazy val e2eSettings =
inConfig(EndToEndTest)(Defaults.testSettings) ++
Seq(
fork in EndToEndTest := false,
parallelExecution in EndToEndTest := false,
scalaSource in EndToEndTest := baseDirectory.value / "src/e2e/scala",
resourceDirectory in EndToEndTest := baseDirectory.value / "src/test/resources")
lazy val settings = e2eSettings ++ itSettings ++ Seq(
testAll <<= (test in EndToEndTest) dependsOn (test in IntegrationTest) dependsOn(test in Test)
)
}
java.lang.NoClassDefFoundError: scoverage/Invoker$
addSbtPlugin("com.mojolly.scalate" % "xsbt-scalate-generator" % "0.5.0")
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.5")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.1.0")
It seems that you need to add a setting to your sbt project:
works for me, with "org.scoverage" % "sbt-scoverage" % "1.5.0"
coverageEnabled in Test := true
and I have found that for version <1.4.0 there was another solution:
coverageEnabled.in(ThisBuild ,Test, test) := true

SBT Web Plugin : Error getting ScopedKey(Scope(This,Select(ConfigKey(container)),This,This),full-classpath)

I'm trying to set up scala web project with sbt. I've following settings.
scala 2.9.0-1
sbt 0.11.0
xsbt-web-plugin 0.2.1
project/plugins.sbt
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.1"))
project/TaskTrackerBuild.scala
import sbt._
import com.github.siasia._
import WebPlugin._
import PluginKeys._
import Keys._
/**
* Main sbt build file for the task-tracker project.
*
*/
object TicketingCoreProject extends Build {
val ticketingVersion = "1.0.0-SNAPSHOT"
val Organization = "org.sansoft"
val ScalaVersion = "2.9.0-1"
val jodaTime = "joda-time" % "joda-time" % "1.6"
val scalaTime = "org.scala-tools.time" % "time_2.8.0" % "0.2"
val casbah = "com.mongodb.casbah" % "casbah_2.9.0-1" % "2.1.5.0"
val Slf4jLog4jDep = "org.slf4j" % "slf4j-log4j12" % "1.6.1"
val ScalaCheckDep = "org.scala-tools.testing" %% "scalacheck" % "1.9" % "test"
val JUnitDep = "junit" % "junit" % "4.8.2" % "test"
val scalaTesting = "org.scala-tools.testing" %% "specs" % "1.6.8" % "test"
//val scctSbt = "ch.craven" %% "scct-plugin" % "0.2"
val vaadin = "com.vaadin" % "vaadin" % "6.7.0"
val jettyWebApp = "org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "container"
val jettyPlus = "org.eclipse.jetty" % "jetty-plus" % "7.3.0.v20110203" % "container"
val repositories = Seq(
ScalaToolsSnapshots,
"typesafe releases" at "http://repo.typesafe.com/typesafe/releases",
"typesafe snapshots" at "http://repo.typesafe.com/typesafe/snapshots",
"scct-repo" at "http://mtkopone.github.com/scct/maven-repo")
def publishToRepository = Some(Resolver.file("Local Maven Repository", Path.userHome / ".m2" / "repository" asFile))
lazy val baseSettings = Defaults.defaultSettings ++ Seq(
version := ticketingVersion,
organization := Organization,
scalaVersion := ScalaVersion,
publishMavenStyle := true,
publishTo := publishToRepository,
resolvers ++= repositories,
checksums := Nil
)
lazy val parent = Project("taskTrackerParent", file("."),
settings = baseSettings ++ Seq(
name := "task-tracker-parent"
))
lazy val core = Project("core", file("core"),
settings = baseSettings ++ Seq(
name := "core",
libraryDependencies ++= Seq(
jodaTime,
scalaTime,
scalaTesting,
ScalaCheckDep,
casbah,
jodaTime,
scalaTime)))
lazy val web = Project("web", file("web"),
settings = baseSettings ++ webSettings ++ Seq(
name := "web",
libraryDependencies ++= Seq(
jodaTime,
scalaTime,
scalaTesting,
ScalaCheckDep,
casbah,
jodaTime,
scalaTime,
vaadin,
jettyWebApp,
jettyPlus))) dependsOn(core)
}
When I try to start sbt with this build file I get following error.
[error] Error getting ScopedKey(Scope(This,Select(ConfigKey(container)),This,This),full-classpath)
[error] Use 'last' for the full log.
If I remove the configuration webSettings from the web project sbt project compiles fine.
What have I done wrong in this???
Thanks in advance.
I had exactly the same issue when I tried to use webSettings.
Today I found a solution on project-doc:
https://github.com/siasia/xsbt-web-plugin/wiki/Deployment-scenarios
The plugin works when I change from webSettings to webAppSettings.