Trying to create Unit tests for Slick database for Play web application in Scala - scala

I am struggling trying to configure unit tests for my Play web applications using Scala. I am using Play 2.6 and Scala 2.11.8. When I use the database configuration and execute sbt test I get the error No implementation for play.api.db.slick.DatabaseConfigProvider was bound on my console. So I am going to show how I set my web app and maybe someone could point what is wrong. Just for the sake, the web application is working well. It is just the unit test for the database that I cannot create.
build.sbt
import play.sbt.PlayImport._
name := """crypto-miners-demo"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.8"
libraryDependencies += guice
libraryDependencies += evolutions
libraryDependencies += jdbc
libraryDependencies += filters
libraryDependencies += ws
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += "com.typesafe.play" %% "anorm" % "2.5.3"
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.0" % Test
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.0"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.0"
libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.19.3"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.2.0"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.2.0"
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.6.5"
application.conf:
play.application.loader = di.ApplicationLoader
play.filters.csrf.header.bypassHeaders {
X-Requested-With = "*"
Csrf-Token = "nocheck"
}
play.filters.csrf.bypassCorsTrustedOrigins = false
play.filters.disabled += play.filters.csrf.CSRFFilter
slick.dbs.default.profile = "slick.jdbc.SQLiteProfile$"
slick.dbs.default.db.driver = "org.sqlite.JDBC"
slick.dbs.default.db.url = "jdbc:sqlite:development.db"
slick.dbs.default.db.username = ""
slick.dbs.default.db.password = ""
db.default {
driver = org.sqlite.JDBC
url = "jdbc:sqlite:development.db"
username = ""
password = ""
}
play.modules.disabled += "play.api.db.DBModule"
RackRepositorySpec.scala:
import org.scalatestplus.play.PlaySpec
import org.scalatestplus.play.guice.GuiceOneAppPerTest
import play.api.db.evolutions._
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.{Database, Databases}
import play.api.inject.bind
import play.api.inject.guice.GuiceInjectorBuilder
import play.api.test.Injecting
class RackRepositorySpec extends PlaySpec with GuiceOneAppPerTest with Injecting {
val database = Databases(
driver = "org.sqlite.JDBC",
url = "jdbc:sqlite:development.db",
name = "default",
config = Map(
"username" -> "",
"password" -> ""
)
)
val guice = new GuiceInjectorBuilder()
.overrides(bind[Database].toInstance(database))
.injector()
val defaultDbProvider = guice.instanceOf[DatabaseConfigProvider]
def beforeAll() = Evolutions.applyEvolutions(database)
def afterAll() = {
// Evolutions.cleanupEvolutions(database)
database.shutdown()
}
Evolution(
1,
"create table test (id bigint not null, name varchar(255));",
"drop table test;"
)
}
and I get this error when I execute sbt test:
[info] models.RackRepositorySpec *** ABORTED ***
[info] com.google.inject.ConfigurationException: Guice configuration errors:
[info]
[info] 1) No implementation for play.api.db.slick.DatabaseConfigProvider was bound.
[info] while locating play.api.db.slick.DatabaseConfigProvider
[info]
[info] 1 error
[info] at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1045)
[info] at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
[info] at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
[info] at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:409)
[info] at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:404)
[info] at play.api.inject.ContextClassLoaderInjector$$anonfun$instanceOf$2.apply(Injector.scala:117)
[info] at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:126)
[info] at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:117)
[info] at models.RackRepositorySpec.<init>(RackRepositorySpec.scala:26)
[info] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

I solved using the libraryDependencies += specs2 % Test in the build.sbt. I hope this is a good practice for slick:
import org.specs2.mutable.Specification
import play.api.Application
import play.api.test.WithApplicationLoader
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.DurationInt
class RackRepositorySpec extends Specification {
"RackRepository" should {
"work as expected" in new WithApplicationLoader {
val app2dao = Application.instanceCache[RackRepository]
val rackRepository: RackRepository = app2dao(app)
Await.result(rackRepository.delete("r-1"), 3 seconds)
Await.result(rackRepository.delete("r-2"), 3 seconds)
Await.result(rackRepository.delete("r-3"), 3 seconds)
val testRacks = Set(
RackRow("r-1", 0.2F, System.currentTimeMillis()),
RackRow("r-2", 0.5F, System.currentTimeMillis()),
RackRow("r-3", 0.8F, System.currentTimeMillis())
)
Await.result(Future.sequence(testRacks.map(rackRepository.insert)), 3 seconds)
val storedRacks = Await.result(rackRepository.list(), 3 seconds)
storedRacks.toSet must contain(testRacks)
}
}
}

Related

Scala Flink get java.lang.NoClassDefFoundError: scala/Product$class after using case class for customized DeserializationSchema

It work fine when using generic class.
But get java.lang.NoClassDefFoundError: scala/Product$class error after change class to case class.
Not sure is sbt packaging problem or code problem.
When I'm using:
sbt
scala: 2.11.12
java: 8
sbt assembly to package
package example
import java.util.Properties
import java.nio.charset.StandardCharsets
import org.apache.flink.api.scala._
import org.apache.flink.streaming.util.serialization.{DeserializationSchema, SerializationSchema}
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.streaming.connectors.kafka.{FlinkKafkaConsumer, FlinkKafkaProducer}
import org.apache.flink.streaming.api.watermark.Watermark
import org.apache.flink.streaming.api.functions.AssignerWithPunctuatedWatermarks
import org.apache.flink.api.common.typeinfo.TypeInformation
import Config._
case class Record(
id: String,
startTime: Long
) {}
class RecordDeSerializer extends DeserializationSchema[Record] with SerializationSchema[Record] {
override def serialize(record: Record): Array[Byte] = {
return "123".getBytes(StandardCharsets.UTF_8)
}
override def deserialize(b: Array[Byte]): Record = {
Record("1", 123)
}
override def isEndOfStream(record: Record): Boolean = false
override def getProducedType: TypeInformation[Record] = {
createTypeInformation[Record]
}
}
object RecordConsumer {
def main(args: Array[String]): Unit = {
val config : Properties = {
var p = new Properties()
p.setProperty("zookeeper.connect", Config.KafkaZookeeperServers)
p.setProperty("bootstrap.servers", Config.KafkaBootstrapServers)
p.setProperty("group.id", Config.KafkaGroupID)
p
}
val env = StreamExecutionEnvironment.getExecutionEnvironment
env.enableCheckpointing(1000)
var consumer = new FlinkKafkaConsumer[Record](
Config.KafkaTopic,
new RecordDeSerializer(),
config
)
consumer.setStartFromEarliest()
val stream = env.addSource(consumer).print
env.execute("record consumer")
}
}
Error
2020-08-05 04:07:33,963 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator - Discarding checkpoint 1670 of job 4de8831901fa72790d0a9a973cc17dde.
java.lang.NoClassDefFoundError: scala/Product$class
...
build.SBT
First idea is that maybe version is not right.
But every thing work fine if use normal class
Here is build.sbt
ThisBuild / resolvers ++= Seq(
"Apache Development Snapshot Repository" at "https://repository.apache.org/content/repositories/snapshots/",
Resolver.mavenLocal
)
name := "deedee"
version := "0.1-SNAPSHOT"
organization := "dexterlab"
ThisBuild / scalaVersion := "2.11.8"
val flinkVersion = "1.8.2"
val flinkDependencies = Seq(
"org.apache.flink" %% "flink-scala" % flinkVersion % "provided",
"org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided",
"org.apache.flink" %% "flink-streaming-java" % flinkVersion % "provided",
"org.apache.flink" %% "flink-connector-kafka" % flinkVersion,
)
val thirdPartyDependencies = Seq(
"com.github.nscala-time" %% "nscala-time" % "2.24.0",
"com.typesafe.play" %% "play-json" % "2.6.14",
)
lazy val root = (project in file(".")).
settings(
libraryDependencies ++= flinkDependencies,
libraryDependencies ++= thirdPartyDependencies,
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
)
assembly / mainClass := Some("dexterlab.TelecoDataConsumer")
// make run command include the provided dependencies
Compile / run := Defaults.runTask(Compile / fullClasspath,
Compile / run / mainClass,
Compile / run / runner
).evaluated
// stays inside the sbt console when we press "ctrl-c" while a Flink programme executes with "run" or "runMain"
Compile / run / fork := true
Global / cancelable := true
// exclude Scala library from assembly
assembly / assemblyOption := (assembly / assemblyOption).value.copy(includeScala = false)
autoCompilerPlugins := true
Finally success after I add this line in build.sbt
assembly / assemblyOption := (assemblu / assemblyOption).value.copy(includeScala = true)
To include scala library when running sbt assembly

Need help in setup of Redshift and Scala using Play

I am new to Scala and Redshift, I am trying to connect redshift with play framework. I have tried a couple of things but still not able to connect. i am using these configurations
db.default.driver=org.redshift.Driver
db.default.url="jdbc:redshift://url:5439/myDb?"
db.default.username="name"
db.default.password="password"
play.modules.enabled += "scalikejdbc.PlayModule"
# scalikejdbc.PlayModule doesn't depend on Play's DBModule
play.modules.disabled += "play.api.db.DBModule"
My SBT file looks like this
scalaVersion := "2.12.4"
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
// https://mvnrepository.com/artifact/com.typesafe.play/anorm
libraryDependencies ++= Seq(
"org.scalikejdbc" %% "scalikejdbc" % "3.2.1",
"com.h2database" % "h2" % "1.4.196",
"ch.qos.logback" % "logback-classic" % "1.2.3"
)
// https://mvnrepository.com/artifact/com.amazon/redshift-jdbc41
resolvers += "redshift" at "http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release"
libraryDependencies += "com.amazon.redshift" % "redshift-jdbc4" % "1.2.10.1009
"
I am getting this error connecting DB
Setup Redshift with Play Scala
Application.conf
db.default.driver=com.amazon.redshift.jdbc4.Driver
db.default.url="jdbc:redshift://url:5439/db"
db.default.username="name"
db.default.password="password"
SBT file
libraryDependencies += jdbc
libraryDependencies ++= Seq(
"org.scalikejdbc" %% "scalikejdbc" % "3.2.0",
"org.scalikejdbc" %% "scalikejdbc-config" % "3.2.0",
"org.scalikejdbc" %% "scalikejdbc-play-initializer" % "2.6.0-scalikejdbc-3.2"
)
// https://mvnrepository.com/artifact/com.amazon/redshift-jdbc41
resolvers += "redshift" at "http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release"
libraryDependencies += "com.amazon.redshift" % "redshift-jdbc4" % "1.2.10.1009"
Controller
package controllers
import javax.inject._
import play.api._
import play.api.mvc._
import play.api.db._
/**
* This controller creates an `Action` to handle HTTP requests to the
* application's home page.
*/
#Singleton
class HomeController #Inject()(db: Database, cc: ControllerComponents) extends AbstractController(cc) {
/**
* Create an Action to render an HTML page.
*
* The configuration in the `routes` file means that this method
* will be called when the application receives a `GET` request with
* a path of `/`.
*/
def index() = Action {
var outString = "Number is "
val conn = db.getConnection()
try {
val stmt = conn.createStatement
val rs = stmt.executeQuery("SELECT 9 as testkey ")
while (rs.next()) {
outString += rs.getString("testkey")
}
} finally {
conn.close()
}
Ok(outString)
// implicit request: Request[AnyContent] =>
//
// Ok(views.html.index())
}
}

Why does SBT compile just the last subproject?

I'm getting crazy, really :-(
Given the following SBT build file...
import sbt._
import sbt.Keys._
object BrixBuild extends Build {
lazy val buildSettings = Project.defaultSettings ++ Seq(
organization := "com.mycompany",
version := "0.1-SNAPSHOT",
scalaVersion := "2.10.0-RC3",
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-deprecation", "-feature", "-unchecked"),
resolvers += Resolvers.typesafe,
target := file("target")
)
lazy val util = Project(
id = "brix-util",
base = file("brix-util"),
settings = buildSettings ++ Seq(
libraryDependencies ++= Dependencies.util
)
)
lazy val slick = Project(
id = "brix-slick",
base = file("brix-slick"),
settings = buildSettings ++ Seq(
libraryDependencies ++= Dependencies.slick
)
)
}
object Resolvers {
val typesafe = "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases"
}
object Dependencies {
private object Compile {
val commonsCodec = "commons-codec" % "commons-codec" % "1.7"
val slick = "com.typesafe" %% "slick" % "1.0.0-RC1"
}
private object Test {
val specs2 = "org.specs2" %% "specs2" % "1.12.3" % "test"
val slf4j = "org.slf4j" % "slf4j-nop" % "1.6.4" % "test"
val h2 = "com.h2database" % "h2" % "1.3.166" % "test"
}
val util = Seq(Compile.commonsCodec, Test.specs2, Test.slf4j)
val slick = Seq(Compile.slick, Test.specs2, Test.slf4j, Test.h2)
}
... only the last subproject get compiled. Why? Am I missing something?
Any help would be really appreciated. Tx.
You should define a "parent" project that aggregates the subprojects. For an example see https://github.com/typesafehub/scalalogging/blob/master/project/Build.scala.

How can I add jars from more than one unmanaged directory in an SBT .scala project configuration

I'm trying to get SBT to build a project that could have more than one unmanaged directory. If I had a single directory, I could easily do it like this:
unmanagedBase := file( "custom-libs" ).getAbsoluteFile
But since I have two directories with unmanaged jars, I need to be able to add them all. I have found some information in here, but still doesn't seem useful for my full .scala file build.
I have created a simple project that shows the issue in here. And below is my Build.scala file.
UPDATE
I've got some help form the sbt-users list and have been able to define the unmanaged-jars correctly, but the code still doesn't compile (but sbt show unmanaged-jars shows the files correctly).
import sbt._
import com.github.siasia._
import PluginKeys._
import Keys._
object Build extends sbt.Build {
import Dependencies._
val unmanagedListing = unmanagedJars := {
Dependencies.listUnmanaged( file(".").getAbsoluteFile )
}
lazy val myProject = Project("spray-template", file("."))
.settings(WebPlugin.webSettings: _*)
.settings(port in config("container") := 8080)
.settings(
organization := "com.example",
version := "0.9.0-RC1",
scalaVersion := "2.9.1",
scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
resolvers ++= Dependencies.resolutionRepos,
libraryDependencies ++= Seq(
Compile.akkaActor,
Compile.sprayServer,
Test.specs2,
Container.jettyWebApp,
Container.akkaSlf4j,
Container.slf4j,
Container.logback
),
unmanagedListing
)
}
object Dependencies {
val resolutionRepos = Seq(
ScalaToolsSnapshots,
"Typesafe repo" at "http://repo.typesafe.com/typesafe/releases/",
"spray repo" at "http://repo.spray.cc/"
)
def listUnmanaged( base : RichFile ) : Keys.Classpath = {
val baseDirectories = (base / "custom-libs") +++ ( base / "custom-libs2" )
(baseDirectories ** "*.jar").classpath
}
object V {
val akka = "1.3"
val spray = "0.9.0-RC1"
val specs2 = "1.7.1"
val jetty = "8.1.0.v20120127"
val slf4j = "1.6.4"
val logback = "1.0.0"
}
object Compile {
val akkaActor = "se.scalablesolutions.akka" % "akka-actor" % V.akka % "compile"
val sprayServer = "cc.spray" % "spray-server" % V.spray % "compile"
}
object Test {
val specs2 = "org.specs2" %% "specs2" % V.specs2 % "test"
}
object Container {
val jettyWebApp = "org.eclipse.jetty" % "jetty-webapp" % V.jetty % "container"
val akkaSlf4j = "se.scalablesolutions.akka" % "akka-slf4j" % V.akka
val slf4j = "org.slf4j" % "slf4j-api" % V.slf4j
val logback = "ch.qos.logback" % "logback-classic" % V.logback
}
}
I just post the fragment from my build.sbt file, using sbt 0.11.x. It could probably be refactored a bit.
unmanagedJars in Compile <++= baseDirectory map { base =>
val libs = base / "lib"
val dirs = (libs / "batik") +++ (libs / "libtw") +++ (libs / "kiama")
(dirs ** "*.jar").classpath
}
You can add additional paths to the list of folders to scan for unmanaged dependencies. For example, to look in a folder called "config" in addition to "lib" for the run task, you can add the following. For the compile task change Runtime to Compile.
unmanagedClasspath in Runtime <+= (baseDirectory) map {
bd => Attributed.blank(bd / "config")
}
As answered by Eugene Vigdorchik, what made it work as the following code:
import sbt._
import com.github.siasia._
import PluginKeys._
import Keys._
object Build extends sbt.Build {
import Dependencies._
var unmanagedListing = unmanagedJars in Compile := {
Dependencies.listUnmanaged( file(".").getAbsoluteFile )
}
lazy val myProject = Project("spray-template", file("."))
.settings(WebPlugin.webSettings: _*)
.settings(port in config("container") := 8080)
.settings(
organization := "com.example",
version := "0.9.0-RC1",
scalaVersion := "2.9.1",
scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
resolvers ++= Dependencies.resolutionRepos,
libraryDependencies ++= Seq(
C.akkaActor,
C.sprayServer,
Test.specs2,
Container.jettyWebApp,
Container.akkaSlf4j,
Container.slf4j,
Container.logback
),
unmanagedListing
)
}
object Dependencies {
val resolutionRepos = Seq(
ScalaToolsSnapshots,
"Typesafe repo" at "http://repo.typesafe.com/typesafe/releases/",
"spray repo" at "http://repo.spray.cc/"
)
def listUnmanaged( base : RichFile ) : Keys.Classpath = {
val baseDirectories = (base / "custom-libs") +++ ( base / "custom-libs2" )
(baseDirectories ** "*.jar").classpath
}
object V {
val akka = "1.3"
val spray = "0.9.0-RC1"
val specs2 = "1.7.1"
val jetty = "8.1.0.v20120127"
val slf4j = "1.6.4"
val logback = "1.0.0"
}
object C {
val akkaActor = "se.scalablesolutions.akka" % "akka-actor" % V.akka % "compile"
val sprayServer = "cc.spray" % "spray-server" % V.spray % "compile"
}
object Test {
val specs2 = "org.specs2" %% "specs2" % V.specs2 % "test"
}
object Container {
val jettyWebApp = "org.eclipse.jetty" % "jetty-webapp" % V.jetty % "container"
val akkaSlf4j = "se.scalablesolutions.akka" % "akka-slf4j" % V.akka
val slf4j = "org.slf4j" % "slf4j-api" % V.slf4j
val logback = "ch.qos.logback" % "logback-classic" % V.logback
}
}
Source repo with the full example available on Github.
Here's a general solution to recursive loading of unmanaged JARs (for sbt 0.13.x): https://stackoverflow.com/a/29357699/1348306

sbt web plugin: Not a valid key: jetty-run (similar: jetty-port, jetty-context, run)

I'm trying to set up a scala sbt project with the lift web framework. I'm using
scala 2.9.0-1
sbt 0.10.1
lift 2.3
xsbt-web-plugin 0.1.1 (which is only on scala 2.8.1, see end of question)
(quite recent versions I know).
I followed http://d.hatena.ne.jp/k4200/20110711/1310354698 and https://github.com/siasia/xsbt-web-plugin/blob/master/README.md to obtain the following sbt configuration files:
project/build.properties
sbt.version=0.10.1
project/plugins/build.sbt
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
libraryDependencies <+= sbtVersion(v => "com.github.siasia" % "xsbt-web-plugin_2.8.1" % ("0.1.1-"+v))
project/Build.scala
import sbt._
import Keys._
object BuildSettings {
val buildOrganization = "xbaz"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.0.1"
val buildSettings = Defaults.defaultSettings ++ Seq (
organization := buildOrganization,
scalaVersion := buildScalaVersion,
version := buildVersion)
}
object Resolvers {
val webPluginRepo = "Web plugin repo" at "http://siasia.github.com/maven2"
val jettyRepo = "Jetty Repo" at "http://repo1.maven.org/maven2/org/mortbay/jetty"
}
object Dependencies {
// web plugin
val webPluginDeps = Seq(
"org.mortbay.jetty" % "jetty" % "6.1.26" % "jetty", // The last part is "jetty" not "test".
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
val liftDeps = {
val liftVersion = "2.3" // I'll switch to 2.3 soon!
Seq(
"net.liftweb" % "lift-webkit_2.8.1" % liftVersion % "compile->default",
"net.liftweb" % "lift-mapper_2.8.1" % liftVersion % "compile->default"
)
}
val scalaTest = "org.scalatest" % "scalatest_2.9.0" % "1.6.1" % "test"
val apacheHttpClient = "org.apache.httpcomponents" % "httpclient" % "4.1.1"
val apacheHttpCore = "org.apache.httpcomponents" % "httpcore" % "4.1.1"
// Logging
lazy val grizzled = "org.clapper" % "grizzled-slf4j_2.8.1" % "0.5"
lazy val junit = "junit" % "junit" % "4.8" % "test"
lazy val logback_core = "ch.qos.logback" % "logback-core" % "0.9.24" % "compile" //LGPL 2.1
lazy val logback_classic = "ch.qos.logback" % "logback-classic" % "0.9.24" % "compile" //LGPL 2.1
lazy val log4j_over_slf4j = "org.slf4j" % "log4j-over-slf4j" % "1.6.1"
val logDeps = Seq(grizzled, log4j_over_slf4j, logback_core, logback_classic)
}
object MyBuild extends Build {
import com.github.siasia.WebPlugin._ // web plugin
import BuildSettings._
import Dependencies._
import Resolvers._
//End dependencies
lazy val root = Project("root", file(".") , settings = buildSettings ++
Seq( name := "foo")
) aggregate(core, cli, web)
// mainClass:= Some("Main"))
lazy val core : Project = Project("core", file("core"), delegates = root :: Nil, settings = buildSettings ++
Seq(
name := "foo-core",
libraryDependencies ++= logDeps ++ Seq(scalaTest, apacheHttpClient, apacheHttpCore)
)
)
lazy val cli: Project = Project("cli", file("cli"), settings = buildSettings ++
Seq(
name := "foo-cli",
libraryDependencies ++= logDeps ++ Seq(apacheHttpClient),
fork in run := true,
javaOptions in run += "-Djava.library.path=/home/jolivier/Projets/asknow/lib/jnotify-lib-0.93"
)) dependsOn(core) settings(
)
lazy val web: Project = Project("web", file("web"), settings = buildSettings ++
Seq (resolvers := Seq(webPluginRepo, jettyRepo),
name := "foo-http",
libraryDependencies ++= logDeps ++ webPluginDeps ++ liftDeps
) ++
webSettings
) dependsOn(core)
}
When I try sbt jetty-run I get the following error message:
[error] Not a valid command: jetty-run
[error] Not a valid project ID: jetty-run
[error] Not a valid configuration: jetty-run
[error] Not a valid key: jetty-run (similar: jetty-port, jetty-context, run)
[error] jetty-run
[error]
So I noticed that some jetty-* commands do exist, but not the one I want, so I printed webSettings which is supposed to contain all these new settings and it contains jetty-context and jetty-port, as well as jetty-configuration and others, but not jetty-run :s.
What did I go wrong to not have jetty-run?
I tried switching to scala-2.8.1 since the web plugin is currently only on scala 2.8.1, by changing my buildScalaVersion variable but that didn't change anything. Do you have any idea?
Thanks in advance for your help
Tasks are aggregated; commands are not.
jetty-run is a command. It is only available in the context of the sub-project with the web plugin settings.
> project web
> jetty-run
Once it is running, you can use the prepare-webapp task to redeploy the webapp. This can be run from the context of the root project, because it aggregates the web project.