plugin.sbt: I define resolvers and plugins here.
logLevel := Level.Debug
resolvers += "JCenter repo" at "https://bintray.com/bintray/jcenter/"
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
resolvers += "mvnrepository" at "http://mvnrepository.com/artifact/"
resolvers += "Atlassian Releases" at "https://maven.atlassian.com/public/"
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
build.sbt: There are 3 projects in this file: shared, client and server. Client is a Scala.js application, server is a Play application and shared is a project which code is used in server and client projects.
import sbt.Project.projectToRef
lazy val clients = Seq(client)
lazy val scalaV = "2.11.6"
lazy val server = (project in file("server")).settings(
scalaVersion := scalaV,
scalaJSProjects := clients,
pipelineStages := Seq(scalaJSProd, gzip),
libraryDependencies ++= Seq(
"com.vmunier" %% "play-scalajs-scripts" % "0.3.0",
"org.webjars" % "jquery" % "1.11.1",
"org.json4s" %% "json4s-jackson" % "3.2.11",
"com.github.benhutchison" %% "prickle" % "1.1.7",
"com.kyleu" %% "jdub-async" % "1.0",
specs2 % Test
)
).enablePlugins(PlayScala).
aggregate(clients.map(projectToRef): _*).
dependsOn(exampleSharedJvm)
lazy val client = (project in file("client")).settings(
scalaVersion := scalaV,
persistLauncher := true,
persistLauncher in Test := false,
sourceMapsDirectories += exampleSharedJs.base / "..",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.8.0",
"org.scala-js" %%% "scala-parser-combinators" % "1.0.2",
"com.github.benhutchison" %%% "prickle" % "1.1.7"
)
).enablePlugins(ScalaJSPlugin, ScalaJSPlay).
dependsOn(exampleSharedJs)
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared")).
settings(scalaVersion := scalaV).
jsConfigure(_ enablePlugins ScalaJSPlay).
jsSettings(sourceMapsBase := baseDirectory.value / "..")
lazy val exampleSharedJvm = shared.jvm
lazy val exampleSharedJs = shared.js
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value
During compilation of server project I got an error: unresolved dependency: com.kyleu#jdub-async_2.11;1.0: not found. How to fix this issue?
Related
I'm trying to use sbt JmhPlugin and I'm following the instructions found here: https://github.com/sbt/sbt-jmh
So I added the plugin to project/plugins.sbt and then I added to build.sbt the enablePlugins(JmhPlugin) line so my build files look like this:
project/plugins.sbt:
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.4")
project/build.properties:
sbt.version = 1.8.2
build.sbt:
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.10"
lazy val root = (project in file("."))
.settings(
name := "myproj"
)
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.15"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % "test"
libraryDependencies += "org.typelevel" %% "cats-effect" % "2.5.3"
val catsVersion = "2.9.0"
libraryDependencies += "org.typelevel" %% "cats-core" % catsVersion
libraryDependencies += "org.typelevel" %% "cats-free" % catsVersion
libraryDependencies += "org.typelevel" %% "cats-laws" % catsVersion
libraryDependencies += "org.typelevel" %% "cats-mtl-core" % "0.7.1"
libraryDependencies += "org.typelevel" %% "simulacrum" % "1.0.1"
libraryDependencies += "org.scalamacros" %% "resetallattrs" % "1.0.0"
libraryDependencies += "org.scalameta" %% "munit" % "0.7.22"
libraryDependencies += "org.typelevel" %% "discipline-munit" % "1.0.6"
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:_",
"-Ymacro-annotations"
)
enablePlugins(JmhPlugin)
but when I'm running sbt build it complains that it cannot find the JmhPlugin:
error: not found: value JmhPlugin
enablePlugins(JmhPlugin)
^
What am I doing wrong here? Also, how should I debug this issue?
Thanks!
I am trying to upgrade mumoshu's Memcached Plugin for Play framework, to Play 2.8.6, in build.sbt.
The upgrade instructions are:
For Play 2.6.x and newer: !!! Changed play.modules.cache.* config keys to play.cache.* !!!
val appDependencies = Seq(
play.PlayImport.cacheApi,
"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = Project(appName).enablePlugins(play.PlayScala).settings(
version := appVersion,
libraryDependencies ++= appDependencies,
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)
Before the upgrade, I had:
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
"com.github.mumoshu" %% "play2-memcached-play24" % "0.7.0",
//...
}
After the (unsuccessful) upgrade:
the cache dependency is not resolved, so I removed it.
The updated build.sbt now looks like this:
name := "CH07"
version := "1.0"
lazy val `ch07` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.4"
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2"
val appDependencies = Seq(
play.sbt.PlayImport.cache,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
//"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = (project in file(".")).enablePlugins(play.sbt.PlayScala).settings(
version := version.value,
libraryDependencies ++= appDependencies,
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)
libraryDependencies ++= Seq(
jdbc,
//cache,
ws,
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.jooq" % "jooq" % "3.14.4",
"org.jooq" % "jooq-codegen-maven" % "3.14.4",
"org.jooq" % "jooq-meta" % "3.14.4",
"joda-time" % "joda-time" % "2.7",
"com.github.ironfish" %% "akka-persistence-mongo-casbah" % "0.7.6",
"com.ning" % "async-http-client" % "1.9.29"
)
routesGenerator := InjectedRoutesGenerator
Errors I am getting:
* build.sbt:
error: value cache is not a member of object play.sbt.PlayImport
* build.sbt:
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
Intellij says: unresolved artifact. Not resolved or indexed.
* in project/plugins.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.6")
Intellij says: unresolved artifact. Not resolved or indexed.
Can you see any errors I made in the build.sbt?
In other words, I am looking for a working build.sbt (and the other required definitions) example for a project that uses Play 2.8.6 and the Memcached Plugin for Play framework 0.9.2. (or highest possible version of the latter).
UPDATE:
This is my current configuration which does compile:
build.sbt
name := "CH07"
version := "1.0"
lazy val `ch07` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.4"
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2"
libraryDependencies ++= Seq(
jdbc,
cacheApi,
ws,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.jooq" % "jooq" % "3.14.4",
"org.jooq" % "jooq-codegen-maven" % "3.14.4",
"org.jooq" % "jooq-meta" % "3.14.4",
"joda-time" % "joda-time" % "2.7",
"com.ning" % "async-http-client" % "1.9.29",
"com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
"com.typesafe.akka" %% "akka-persistence" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-query" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-typed" % "2.6.10",
"com.typesafe.play" %% "play-guice" % "2.8.7"
)
routesGenerator := InjectedRoutesGenerator
project/build.properties
sbt.version=1.3.10
project/plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
How about this?
name := """pla-memcache-example"""
organization := "com.example"
version := "1.0-SNAPSHOT"
scalaVersion := "2.13.3"
val appDependencies = Seq(
guice,
play.PlayImport.cacheApi,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
"org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test
)
lazy val root = (project in file(".")).enablePlugins(PlayScala).settings(
version := appVersion,
libraryDependencies ++= appDependencies,
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)
plugins.sbt
sbt.version=1.3.13
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
In this case, first find the giter8 template and use the "sbt new" command.
Next, go to the official page of the plugin and check the name of the library, and then use Maven search to find the version you want to use.
It's a good idea to read the entire readme of the plugin without skipping it.
You can also try to run sbt with commands instead of using IntelliJ.
If that doesn't solve the problem, you can try clearing the cache in the .ivy2 directory.
Reference Links:
https://github.com/mumoshu/play2-memcached
https://github.com/playframework/play-scala-seed.g8
https://search.maven.org/artifact/com.github.mumoshu/play2-memcached-play28_2.13/0.11.0/jar
Your issue is when trying to import play.sbt.PlayImport.cache. According to Cache APIs Migration by play:
New packages
Now `cache` has been split into a `cacheApi` component with just the API, and `ehcache` that contains the Ehcache implementation. If you are using the default Ehcache implementation, simply change `cache` to `ehcache` in your `build.sbt`:
libraryDependencies ++= Seq(
ehcache
)
If you are defining a custom cache API, or are writing a cache implementation module, you can just depend on the API:
libraryDependencies ++= Seq(
cacheApi
)
Removed APIs
The deprecated Java class play.cache.Cache was removed and you now must inject an play.cache.SyncCacheApi or play.cache.AsyncCacheApi.
Therefore a complete build.sbt will be:
name := "CH07"
version := "1.0"
lazy val `ch07` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.4"
resolvers += "Spy Repository" at "https://files.couchbase.com/maven2"
val appDependencies = Seq(
play.sbt.PlayImport.ehcache,
play.sbt.PlayImport.cacheApi,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
//"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = (project in file(".")).enablePlugins(play.sbt.PlayScala).settings(
version := version.value,
libraryDependencies ++= appDependencies,
resolvers += "Spy Repository" at "https://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)
libraryDependencies ++= Seq(
jdbc,
//cache,
ws,
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.jooq" % "jooq" % "3.14.4",
"org.jooq" % "jooq-codegen-maven" % "3.14.4",
"org.jooq" % "jooq-meta" % "3.14.4",
"joda-time" % "joda-time" % "2.7",
"com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
"com.ning" % "async-http-client" % "1.9.29"
)
routesGenerator := InjectedRoutesGenerator
build.properties:
sbt.version=1.4.4
plugins.sbt:
logLevel := Level.Warn
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
I am trying to Save DataFrames to Phoenix using DataSourceV2 following the below mentioned source:
Apache Spark plugin
I created a dataframe and I want to save it to phoenix in the following way:
import org.apache.spark.SparkContext
import org.apache.phoenix.spark.datasource.v2.PhoenixDataSource
val conf = new SparkConf().setAppName("Spark sql to convert rdd to df")
val sc = new SparkContext(conf)
val sqlContext= new org.apache.spark.sql.SQLContext(sc)
import sqlContext.implicits._
val MasterDF = MasterRecordSeq.toDF()
MasterDF.write
.format("phoenix")
.mode(SaveMode.Overwrite)
.options(Map("table" -> masterTableName, PhoenixDataSource.ZOOKEEPER_URL -> "phoenix-server:2181"))
.save()
But the import org.apache.phoenix.spark.datasource.v2.PhoenixDataSource is not being recognized. It throws the following error:
object datasource is not a member of package org.apache.phoenix.spark
I have searched through a lot of internet but I'm not able to find what the bug is.
The following are the dependencies I added in build.sbt:
libraryDependencies += "org.apache.phoenix" % "phoenix-spark" % "5.0.0-HBase-2.0"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.4.5"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.5"
libraryDependencies += "org.apache.phoenix" % "phoenix-core" % "5.0.0-HBase-2.0"
The following is the complete build file:
import NativePackagerHelper._
import java.util.Properties
import com.typesafe.sbt.packager.MappingsHelper._
//import sbtrelease.ReleaseStateTransformations._
name := """gavel"""
//scapegoatVersion in ThisBuild := "1.1.0"
//version := sys.env.get("BUILD_NUMBER").getOrElse("3.0-LOCAL")
version := "3.0"
scalaVersion := "2.11.12"
//crossScalaVersions := Seq("2.11.11", "2.12.3")
//scapegoatVersion in ThisBuild := "1.3.5"
scalaBinaryVersion in ThisBuild := "2.12"
javacOptions ++= Seq("-source", "1.6", "-target", "1.6")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
scalacOptions in (Compile, doc) ++= Seq("-unchecked", "-deprecation", "-diagrams", "-implicits", "-skip-packages", "samples")
lazy val root = (project in file(".")).enablePlugins(PlayScala,sbtdocker.DockerPlugin,JavaAppPackaging).settings(
watchSources ++= (baseDirectory.value / "public/frontend" ** "*").get
)
mainClass := Some("play.core.server.ProdServerStart")
fullClasspath in assembly += Attributed.blank(PlayKeys.playPackageAssets.value)
mappings in Universal ++= directory(baseDirectory.value / "public")
unmanagedBase := baseDirectory.value / "libs"
routesGenerator := InjectedRoutesGenerator
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.3.1",
"mysql" % "mysql-connector-java" % "5.1.34",
"com.typesafe.play" %% "play-slick" % "3.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "3.0.0",
"com.typesafe.play" %% "play-json" % "2.6.0",
"org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % "test",
specs2 % Test,
// "io.rest-assured" % "rest-assured" % "3.0.0" % "test",
// "io.rest-assured" % "scala-support" % "3.0.0" % "test",
// "com.squareup.okhttp" % "mockwebserver" % "2.5.0" % "test",
"javax.mail" % "mail" % "1.4",
"io.swagger" %% "swagger-play2" % "1.6.1",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.4.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.4.0",
"com.google.code.gson" % "gson" % "1.7.1",
"commons-io" % "commons-io" % "2.4",
"com.typesafe.akka" %% "akka-actor" % "2.4.16",
"com.typesafe.akka" %% "akka-testkit" % "2.4.16" % "test",
"org.typelevel" %% "macro-compat" % "1.1.1",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
compilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.full),
guice
)
libraryDependencies ++= Seq(
"com.101tec" % "zkclient" % "0.4",
"org.apache.kafka" % "kafka_2.10" % "0.8.1.1"
exclude("javax.jms", "jms")
exclude("com.sun.jdmk", "jmxtools")
exclude("com.sun.jmx", "jmxri")
)
libraryDependencies += ws
libraryDependencies += ehcache
// https://mvnrepository.com/artifact/org.apache.phoenix/phoenix-spark
libraryDependencies += "org.apache.phoenix" % "phoenix-spark" % "5.0.0-HBase-2.0"
libraryDependencies += "com.google.protobuf" % "protobuf-java" % "2.4.0"
libraryDependencies += "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.13"
libraryDependencies += "com.google.code.gson" % "gson" % "2.3"
libraryDependencies += "org.apache.phoenix" % "phoenix-queryserver-client" % "4.13.1-HBase-1.2"
libraryDependencies += "com.github.takezoe" %% "solr-scala-client" % "0.0.19"
libraryDependencies += "com.squareup.okhttp" % "okhttp" % "2.7.0"
libraryDependencies += "org.threeten" % "threetenbp" % "1.2"
libraryDependencies += "io.gsonfire" % "gson-fire" % "1.0.1"
libraryDependencies += "au.com.bytecode" % "opencsv" % "2.4"
libraryDependencies += "org.simplejavamail" % "simple-java-mail" % "5.0.8"
libraryDependencies += "org.apache.solr" % "solr-solrj" % "6.6.2"
libraryDependencies += "com.jcraft" % "jsch" % "0.1.55"
libraryDependencies += "com.vmware" % "vijava" % "5.1"
libraryDependencies += "com.microsoft.sqlserver" % "mssql-jdbc" % "6.1.0.jre8" % Test
//libraryDependencies += "com.microsoft.sqlserver" % "sqljdbc4" % "4.0"
libraryDependencies += "org.apache.poi" % "poi" % "3.17"
libraryDependencies += "org.apache.poi" % "poi-ooxml" % "3.17"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.4.5"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.5"
libraryDependencies += "org.apache.phoenix" % "phoenix-core" % "5.0.0-HBase-2.0"
crossSbtVersions := Seq("0.13.17", "1.1.6")
publishTo := {
val isSnapshotValue = isSnapshot.value
val nexus = "https://oss.sonatype.org/"
if(isSnapshotValue) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
publishMavenStyle := true
publishArtifact in Test := false
parallelExecution in Test := false
dockerfile in docker := {
// The assembly task generates a fat JAR file
val artifact: File = assembly.value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("java")
from("mysql:5.7")
add(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
}
}
val appProperties = settingKey[Properties]("The application properties")
appProperties := {
val prop = new Properties()
IO.load(prop, new File("./conf/database.conf"))
prop
}
javaOptions in Test += "-Dconfig.file=conf/application.test.conf"
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
sourceDirectories in (Compile, TwirlKeys.compileTemplates) :=
(unmanagedSourceDirectories in Compile).value
flywayDriver := "com.mysql.jdbc.Driver"
flywayUrl := appProperties.value.getProperty("slick.dbs.default.db.url").replaceAll("\"", "")
flywayUser := appProperties.value.getProperty("slick.dbs.default.db.user")
flywayPassword := appProperties.value.getProperty("slick.dbs.default.db.password").replaceAll("\"", "")
flywayLocations := Seq("filesystem:conf/db/default")
fork in run := true
//coverageEnabled := false
//coverageMinimum := 70
//coverageFailOnMinimum := true
//coverageHighlighting := true
publishArtifact in Test := false
parallelExecution in Test := false
enablePlugins(SbtProguard)
import com.lightbend.sbt.SbtProguard._
javaOptions in (Proguard, proguard) := Seq("-Xmx2G")
proguardOptions in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings")
proguardOptions in Proguard += ProguardOptions.keepMain("some.MainClass")
proguardMergeStrategies in Proguard += ProguardMerge.append("*.conf")
proguardMergeStrategies in Proguard ++= Seq(
ProguardMerge.discard("\\.zip$".r),
ProguardMerge.discard("\\.xml$".r),
ProguardMerge.discard("\\.txt$".r),
ProguardMerge.discard("\\.conf$".r),
ProguardMerge.discard("\\.jar$".r)
)
My phoenix version is 5.0. My Hbase version is 2.0.2.3.1.0.0-78. Am I missing any configuration?
I had the same problem (error), but in my specific case it was for a scala script in a Hortonworks Big Data cluster to be executed by Spark
I managed to solve it by compiling the phoenix-spark repository available on github and importing the jar into the spark directory.
Here are the commands I ran to build the jar, I hope it helps.
sudo yum install maven
wget https://github.com/apache/phoenix-connectors/archive/master.zip
unzip master.zip
cd phoenix-connectors/phoenix-spark
mvn clean compile
mvn package
cd target/scala-2.12/
cp phoenix-spark-1.0.0-SNAPSHOT.jar /usr/hdp/current/spark2-client/jars
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.
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