sbtbuildinfo - Building with multiple projects - scala

I am using sbt to build a multi module project, and I want to use sbt-buildinfo to allow one of the services to have this info in it for debugging and versioning purposes.
The problem with this, is that the sbt-buildinfo plugin seems to only take the library dependencies of the root project and not all the dependencies of the aggregated sub projects. It seems to me that if you run the plugin after the aggregation then the root project would have those dependencies in it and would show up, but they do not. Maybe I'm just not understanding the process here, but that seems reasonable to me.
Now, this worked perfectly fine with one project, but with many sub projects it no longer works. In addition now it no longer even generates the File, I don't know what I'm doing wrong at this point. Here is my build. Any help is appreciated.
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Managed
lazy val sharedSettings = Seq(
organization := "com.planalytics",
version := "0.0.1-SNAPSHOT",
name := "Ingestions",
scalaVersion := "2.11.7",
exportJars := true
) ++ net.virtualvoid.sbt.graph.Plugin.graphSettings ++ Defaults.defaultSettings
lazy val sparkVersion = "1.5.1"
lazy val akkaVersion = "2.3.12"
lazy val sprayVersion = "1.3.3"
lazy val hadoopVersion = "2.7.1"
lazy val exclusionRules = Seq(ExclusionRule(organization = "org.slf4j"),
ExclusionRule(organization = "org.apache.hadoop"))
lazy val sharedDeps = Seq(libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-log4j12" % "1.7.10",
"org.scalacheck" %% "scalacheck" % "1.12.0" % "test",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"org.scalanlp" %% "breeze-natives" % "0.11.2"))
lazy val sparkDeps = Seq(libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion excludeAll(exclusionRules: _*),
"org.apache.spark" %% "spark-sql" % sparkVersion excludeAll(exclusionRules: _*),
"org.apache.spark" %% "spark-mllib" % sparkVersion excludeAll(exclusionRules: _*),
"com.databricks" %% "spark-csv" % "1.2.0" excludeAll(exclusionRules: _*),
"org.apache.hadoop" % "hadoop-common" % hadoopVersion,
"org.apache.hadoop" % "hadoop-client" % hadoopVersion,
"org.apache.hadoop" % "hadoop-hdfs" % hadoopVersion,
"org.apache.hadoop" % "hadoop-aws" % hadoopVersion))
lazy val akkaDeps = Seq(libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-cluster" % akkaVersion,
"com.typesafe.akka" %% "akka-remote" % akkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion))
lazy val sprayDeps = Seq(libraryDependencies ++= Seq(
"io.spray" %% "spray-can" % sprayVersion,
"io.spray" %% "spray-routing" % sprayVersion,
"io.spray" %% "spray-json" % "1.3.2"))
lazy val root = (project in file(".")).
settings(sharedSettings: _*).
settings(
scalacOptions += "-deprecation",
javacOptions ++= Seq("-source", "1.8", "target", "1.8"),
javaOptions += "-Xmx2G").aggregate(ingestion, services, util).enablePlugins(BuildInfoPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoOptions += BuildInfoOption.BuildTime,
buildInfoPackage := "com.planalytics",
buildInfoObject := "BuildInfo"
)
lazy val ingestion = Project(
id = "Ingestion-Engine",
base = file("ingestion"),
settings = Project.defaultSettings ++ sharedSettings ++ sparkDeps ++ akkaDeps ++ sharedDeps).
settings(
name := "Ingestion-Engine",
libraryDependencies ++= Seq(
"com.github.seratch" %% "awscala" % "0.5.+",
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test"
)
).dependsOn(util)
lazy val services = Project(
id = "Ingestion-Services",
base = file("services"),
settings = Project.defaultSettings ++ sharedSettings ++ sprayDeps ++ sharedDeps).
settings(
name := "Ingestion-Services",
libraryDependencies ++= Seq(
"io.spray" %% "spray-testkit" % sprayVersion % "test"
)
).dependsOn(ingestion)
lazy val util = Project(
id = "Ingestion-Util",
base = file("util"),
settings = Project.defaultSettings ++ sharedSettings ++ sparkDeps ++ sharedDeps).
settings(
name := "Ingestion-Utils",
libraryDependencies ++= Seq(
"net.ceedubs" %% "ficus" % "1.1.2"
),
dependencyOverrides ++= Set(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.4.4"
)
)
I'm also open to any thoughts on my build in general, I feel like I'm doing some things wrong or repetitively, so any suggestions there is appreciated as well. Thanks!

Related

"datasource not a member of org.apache.phoenix" when trying to Save DataFrames to Phoenix using DataSourceV2

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

Why subprojects does not recognize dependencies?

I've defined two sub projects that looks as follow:
val Http4sVersion = "0.21.0-M4"
val CirceVersion = "0.12.1"
val Specs2Version = "4.7.0"
val LogbackVersion = "1.2.3"
val ScalaTestVersion = "3.0.8"
val TestContainerVersion = "1.11.3"
val KafkaTestContainerVersion = "1.11.3"
val ConfigVersion = "1.3.4"
val SpringVersion = "5.1.8.RELEASE"
val CatsVersion = "2.0.0"
lazy val settings = Seq(
organization := "com.sweetsoft",
name := "connector",
scalaVersion := "2.13.0",
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0"),
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-language:higherKinds",
"-language:postfixOps",
"-feature",
"-Xfatal-warnings",
),
scalacOptions in(Compile, console) ~= {
_.filterNot(Set("-Xlint"))
}
)
lazy val dependencies = Seq(
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-blaze-client" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"io.circe" %% "circe-generic" % CirceVersion,
"ch.qos.logback" % "logback-classic" % LogbackVersion,
"org.typelevel" %% "cats-core" % CatsVersion,
"com.typesafe" % "config" % ConfigVersion % "test",
"org.scalactic" %% "scalactic" % ScalaTestVersion % "test",
"org.scalatest" %% "scalatest" % ScalaTestVersion % "test",
"org.testcontainers" % "testcontainers" % TestContainerVersion % "test",
"org.testcontainers" % "kafka" % KafkaTestContainerVersion % "test",
"org.springframework" % "spring-core" % SpringVersion % "test",
"org.typelevel" %% "cats-laws" % CatsVersion % "test",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.3" % "test",
"org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
)
lazy val global = project
.in(file("."))
.settings(
settings,
libraryDependencies ++= dependencies
)
.aggregate(core, serversupervisor)
lazy val core = (project in file("core"))
.settings(settings)
lazy val serversupervisor = (project in file("serversupervisor"))
.settings(settings)
.dependsOn(core)
As you can see, the two subprojects are core and serversupervisor.
The problem is, that those two subprojects does not recognize dependencies:
I am using Intellj and as you can see, it does not recognize the dependencies.
What am I doing wrong?
Put libraryDependencies ++= dependencies into settings.
global, core and serversupervisor are three different subprojects. They can have different library dependencies. Currently you add them to global but not to core and serversupervisor.
Alternatively you can move libraryDependencies ++= dependencies to Global or
ThisBuild scope rather than specific subproject scope. You can add at top
ThisBuild / libraryDependencies ++= dependencies
or even
Global / libraryDependencies ++= dependencies
https://www.scala-sbt.org/1.x/docs/Multi-Project.html
https://www.scala-sbt.org/1.x/docs/Scopes.html

`java.lang.NoSuchMethodError: cats.FlatMap.map2` in runtime when using `.sequence`

I'm getting the following runtime error after migrating from cats v1.1.0 to v1.4.0 (An error arises from places where .sequence (cats.Traverse) is used).
The code looks like:
import cats.implicits._
import cats.effect.IO
List(1, 2, 3).map(x => IO(...)).sequence
java.lang.NoSuchMethodError: cats.FlatMap.map2$(Lcats/FlatMap;Ljava/lang/Object;Ljava/lang/Object;Lscala/Function2;)Ljava/lang/Object;
at cats.effect.IOLowPriorityInstances$IOEffect.map2(IO.scala:765)
...
Here is my build.sbt:
organization := "org.xxx"
name := "yyy"
version := "0.0.1"
scalaVersion := "2.12.9"
resolvers += Resolver.bintrayRepo("hseeberger", "maven")
resolvers ++= Seq("Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/")
lazy val doobieVersion = "0.5.3"
lazy val akkaHttpVersion = "10.1.1"
lazy val akkaVersion = "2.5.12"
lazy val catsVersion = "1.4.0"
lazy val circeVersion = "0.9.3"
lazy val doobieDeps = Seq(
"org.tpolecat" %% "doobie-core" % doobieVersion,
"org.tpolecat" %% "doobie-postgres" % doobieVersion,
"org.tpolecat" %% "doobie-scalatest" % doobieVersion,
"org.tpolecat" %% "doobie-hikari" % doobieVersion
)
lazy val catsDeps = Seq(
"org.typelevel" %% "cats-effect" % catsVersion,
"org.typelevel" %% "cats-core" % catsVersion
)
lazy val otherDeps = Seq(
"com.github.pureconfig" %% "pureconfig" % "0.9.1",
"org.scorexfoundation" %% "scrypto" % "2.1.1",
"de.heikoseeberger" %% "akka-http-circe" % "1.20.1",
"org.scalaj" %% "scalaj-http" % "2.4.0",
"org.flywaydb" % "flyway-core" % "5.1.1",
"com.github.blemale" %% "scaffeine" % "2.5.0",
("org.scorexfoundation" %% "sigma-state" % "master-2b4b07a1-SNAPSHOT")
.exclude("ch.qos.logback", "logback-classic")
.exclude("org.scorexfoundation", "scrypto"),
)
lazy val circeDeps = Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion
)
libraryDependencies ++= (otherDeps ++ doobieDeps ++ catsDeps ++ loggingDeps ++ akkaDeps ++ circeDeps ++ testDeps)
I've tried to run it different ways (idea, set run) and on different platforms - the result is always the same.
What could it be caused by?
Try to change versions to
"org.typelevel" %% "cats-effect" % "1.4.0",
"org.typelevel" %% "cats-core" % "1.6.1"
Your project seems to work with them.

How to reference a local project in Scala

First of all, apologies if this question has been answered already, or if there's a complete documentation / tutorial about it, I'm a Scala newbie and I've surely missed something.
I have a C# background, and I'm trying to expand my knowledge learning Scala. I would like to include a Scala microservice in a microservices architecture that's actually built using .NET projects. To implement the shared architectural code in the .NET projects I've developed a series of base project, referenced by all the microservices projects, and this operation with VS was pretty straightforward, but I failed to grasp how to achieve the same functionality on Scala.
In particular, I would like to understand whether there's a way to reference a Project A located in a local folder in Project B, in a similar way of referencing a project from Maven like this, for example:
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http-spray-json" % "10.1.1",
"com.typesafe.akka" %% "akka-http" % "10.1.1",
"com.typesafe.akka" %% "akka-stream" % "2.5.11"
)
and what's the best way of doing it (referencing the jars, for example).
Yes you can reference to another scala project in scala using the simple build tool.
Let's say your architecture has
1) ChatMicroserviceApi.jar (depends on two local jars 2 and 3)
2) ChatMicroserviceSchema.jar
3) ChatMicroserviceExternalDeps.jar
Then your sbt script would look like below. I use sbt-assembly to create fat jars for which you have to add addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") in project/plugins.sbt
//build.sbt
name := "ChatMicroserviceParent"
organization in ThisBuild := "com.microservice.chat"
scalaVersion in ThisBuild := "2.12.5"
version := "1.0-SNAPSHOT"
//define what parent consists of in aggregate section
lazy val ChatMicroserviceParent = project
.in(file("."))
.settings(settings)
.aggregate(ChatMicroserviceSchema,
ChatMicroserviceExternalDeps,
ChatMicroserviceApi)
//creates schema.jar
lazy val ChatMicroserviceSchema =
project.settings(name := "ChatMicroserviceSchema",
publishMavenStyle := true,
settings,
apiSchemaAssemblySettings)
//creates external-deps.jar
lazy val ChatMicroserviceExternalDeps =
project.settings(
name := "ChatMicroserviceExternalDeps",
publishMavenStyle := true,
settings,
apiSchemaAssemblySettings,
libraryDependencies ++= Seq(
"com.softwaremill.sttp" %% "core" % "1.1.12",
"com.softwaremill.sttp" %% "async-http-client-backend-future" % "1.1.12"
exclude ("org.asynchttpclient", "async-http-client"),
"org.asynchttpclient" % "async-http-client" % "2.4.4"
excludeAll( ExclusionRule(organization = "io.netty") ),
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.5",
"com.fasterxml.jackson.module" % "jackson-modules-java8" % "2.9.5",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.5",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.9.5"
)
)
val NettyVersion = "4.1.16.Final"
//creates api.jar which depends on schema.jar and external-deps.jar
lazy val ChatMicroserverApi = project
.settings(
name := "ChatMicroserverApi",
settings,
apiAssemblySettings,
libraryDependencies ++= Seq(
"com.github.finagle" %% "finch-core" % "0.18.0"
excludeAll( ExclusionRule(organization = "io.netty") )
exclude ("com.fasterxml.jackson.core", "jackson-databind"),
"com.github.finagle" %% "finch-circe" % "0.18.0",
"io.netty" % "netty-codec" % NettyVersion,
"io.netty" % "netty-codec-http" % NettyVersion,
"io.netty" % "netty-codec-http2" % NettyVersion,
"io.netty" % "netty-transport" % NettyVersion,
"io.netty" % "netty-buffer" % NettyVersion,
"io.netty" % "netty-common" % NettyVersion,
"io.netty" % "netty-resolver" % NettyVersion,
"io.netty" % "netty-handler" % NettyVersion,
"io.netty" % "netty-handler-proxy" % NettyVersion,
"io.netty" % "netty-transport-native-unix-common" % NettyVersion,
"io.netty" % "netty-transport-native-epoll" % NettyVersion,
"io.netty" % "netty-tcnative-boringssl-static" % "2.0.6.Final",
"io.netty" % "netty-codec-socks" % NettyVersion,
"io.circe" %% "circe-generic" % "0.9.3",
"com.typesafe" % "config" % "1.3.3",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.typesafe.akka" %% "akka-actor" % "2.5.12",
"com.typesafe.akka" %% "akka-stream" % "2.5.12",
"com.typesafe.akka" %% "akka-http" % "10.1.1",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.5",
"com.fasterxml.jackson.module" % "jackson-modules-java8" % "2.9.5",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.5",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.9.5",
"io.circe" %% "circe-java8" % "0.9.3",
"com.softwaremill.sttp" %% "core" % "1.1.12",
"org.asynchttpclient" % "async-http-client" % "2.4.4"
excludeAll( ExclusionRule(organization = "io.netty") ),
"com.softwaremill.sttp" %% "async-http-client-backend-future" % "1.1.12"
exclude ("org.asynchttpclient", "async-http-client"),
"joda-time" % "joda-time" % "2.9.9"
)
)
.dependsOn(ChatMicroserviceExternalDeps, ChatMicroserviceSchema)
lazy val commonDependencies = Seq()
lazy val settings =
commonSettings
lazy val compilerOptions = Seq(
"-unchecked",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-deprecation",
"-encoding",
"utf8"
)
lazy val commonSettings = Seq(
scalacOptions ++= compilerOptions,
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
)
)
lazy val apiAssemblySettings = Seq(
assemblyJarName in assembly := name.value + "-" + version.value + ".jar",
mainClass in assembly := Some(
"com.microservice.MainServerClass"),
assemblyMergeStrategy in assembly := {
case PathList("reference.conf") => MergeStrategy.concat
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
)
lazy val apiSchemaAssemblySettings = Seq(
assemblyJarName in assembly := name.value + "-" + version.value + ".jar")
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
lazy val apiExternalDepsAssemblySettings = Seq(
assemblyJarName in assembly := name.value + "-" + version.value + ".jar")
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
Here's working example which might help - https://github.com/duwamish-os/chat-server

sbt assembly error deduplicate

Getting started with sbt.
I am getting this error during sbt assembly
deduplicate: different file contents found in the following:
../.ivy2/cache/org.scalatest/scalatest_2.11/bundles/scalatest_2.11-2.2.6.jar:org/scalactic/SeqEqualityConstraints$.class
../.ivy2/cache/org.scalactic/scalactic_2.11/bundles/scalactic_2.11-3.0.0.jar:org/scalactic/SeqEqualityConstraints$.class
this is my build sbt :
scalaVersion := "2.11.8"
scalacOptions := Seq("-unchecked", "-feature", "-deprecation", "-encoding", "utf8")
libraryDependencies ++= {
val phantomV = "1.29.5"
val scalaTestV = "2.2.6"
val scalaMockV = "3.4.2"
val elastic4sV = "2.4.0"
val akkaStreamVersion = "2.4.10"
val akkaVersion = "2.3.12"
Seq(
"com.websudos" %% "phantom-dsl" % phantomV,
"com.websudos" %% "phantom-reactivestreams" % phantomV,
"com.websudos" %% "util-testing" % "0.13.0" % "test, provided",
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-http-spray-json-experimental" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-core" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-experimental" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-stream" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaStreamVersion,
"org.scalatest" %% "scalatest" % scalaTestV % "test, provided",
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test, provided",
"com.typesafe.play" %% "play-streams-experimental" % "2.4.6" % "provided",
"com.sksamuel.elastic4s" %% "elastic4s-core" % elastic4sV,
"com.sksamuel.elastic4s" %% "elastic4s-streams" % elastic4sV,
"org.scalamock" %% "scalamock-scalatest-support" % scalaMockV % "test, provided",
"com.typesafe" % "config" % "1.3.1"
)
}
lazy val root = project.in(file("."))
.settings(mainClass in assembly := Some("com.ind.Main"))
initialCommands := """|import akka.actor._
|import akka.pattern._
|import akka.util._
|import scala.concurrent._
|import scala.concurrent.duration._""".stripMargin
fork in run := true
test in assembly := {}
any idea why am getting that and how can I solve it ?
===== UPDATE ====
I did managed to solve it by adding
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
The ScalaTest and Scalactic version numbers need to match. You have a ScalaTest 2.2.6 trying to use a Scalactic 3.0.0, so that's the problem. One of your dependencies is perhaps using Scalactic 3.0.0.