Last active
September 8, 2017 12:09
-
-
Save meddulla/b1ec2d2c47577ee7f549a40ad8c40a88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sbt.ExclusionRule | |
| name := """xxx-importer""" | |
| scalaVersion := "2.11.7" | |
| lazy val app = (project in file(".")).enablePlugins(JavaServerAppPackaging) | |
| resolvers ++= Seq( | |
| "Typesafe repository snapshots" at "http://repo.typesafe.com/typesafe/snapshots/", | |
| "Typesafe repository releases" at "http://repo.typesafe.com/typesafe/releases/", | |
| "Sonatype repo" at "https://oss.sonatype.org/content/groups/scala-tools/", | |
| "Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases", | |
| "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", | |
| "Sonatype staging" at "http://oss.sonatype.org/content/repositories/staging", | |
| "Java.net Maven2 Repository" at "http://download.java.net/maven/2/", | |
| "Twitter Repository" at "http://maven.twttr.com", | |
| Resolver.bintrayRepo("websudos", "oss-releases") | |
| ) | |
| libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test" | |
| libraryDependencies += "org.scalamock" %% "scalamock-scalatest-support" % "3.2" % "test" | |
| libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.5" | |
| libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" | |
| libraryDependencies += "com.typesafe" % "config" % "1.2.1" | |
| libraryDependencies += "joda-time" % "joda-time" % "2.3" | |
| libraryDependencies += "org.joda" % "joda-convert" % "1.7" | |
| // cassandra | |
| val PhantomVersion = "1.21.0" | |
| libraryDependencies ++= Seq( | |
| "com.websudos" %% "phantom-dsl" % PhantomVersion exclude("joda-time", "joda-time"), | |
| "com.websudos" %% "phantom-testkit" % "1.12.2" % "test, provided", | |
| "javax.mail" % "mail" % "1.4.7" | |
| ) | |
| libraryDependencies += "org.elasticsearch" % "elasticsearch" % "2.3.0" exclude("joda-time", "joda-time") | |
| libraryDependencies += "xxx.com" %% "xxx-core" % "0.1-SNAPSHOT" exclude("joda-time", "joda-time") | |
| fork in run := true | |
| fork in Test := true | |
| parallelExecution in Test := false | |
| javaOptions in run ++= Seq( | |
| // Use separate configuration file for deploy environment | |
| s"-Dconfig.file=./conf/application.conf" | |
| ) | |
| javaOptions in Test ++= Seq( | |
| // Use separate configuration file for test environment | |
| s"-Dconfig.file=./conf/test.conf" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.text.SimpleDateFormat | |
| import java.util.Calendar | |
| import com.typesafe.sbt.packager.archetypes.{ServerLoader, TemplateWriter} | |
| // run as sbt clean compile; sbt -DappEnv=dev -DcurrentCommit=2e2d526 debian:packageBin | |
| def timestamper() = { | |
| val today = Calendar.getInstance().getTime() | |
| new SimpleDateFormat("yyyyMMddHHmm").format(today) | |
| } | |
| val appEnv = sys.props.getOrElse("appEnv", "dev") | |
| val currentCommit = sys.props.getOrElse("currentCommit", "") | |
| val tmst = timestamper() | |
| val versionNumber = "0.1.5" | |
| val versionEnv:String = if (appEnv.toString == "dev") { s"$versionNumber-$tmst.$currentCommit" } else { s"$versionNumber" } | |
| version := versionEnv | |
| // assemby settings | |
| test in assembly := {} | |
| mainClass in assembly := Some("com.xxx.importer.Main") | |
| assemblyJarName in assembly := "xxx-importer.jar" | |
| assemblyMergeStrategy in assembly := { | |
| case PathList("netty", "handler", xs@_*) => MergeStrategy.first | |
| case PathList("netty", "buffer", xs@_*) => MergeStrategy.first | |
| case PathList("netty", "common", xs@_*) => MergeStrategy.first | |
| case PathList("netty", "transport", xs@_*) => MergeStrategy.first | |
| case PathList("netty", "codec", xs@_*) => MergeStrategy.first | |
| case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.first | |
| case x => | |
| val oldStrategy = (assemblyMergeStrategy in assembly).value | |
| oldStrategy(x) | |
| } | |
| // removes all jar mappings in universal and appends the fat jar | |
| mappings in Universal <<= (mappings in Universal, assembly in Compile) map { (mappings, fatJar) => | |
| val filtered = mappings filter { case (file, name) => ! name.endsWith(".jar") } | |
| filtered :+ (fatJar -> ("lib/" + fatJar.getName)) | |
| } | |
| mappings in Universal += { | |
| file("conf/application.conf") -> "conf/application.conf" | |
| } | |
| mappings in Universal += { | |
| file("conf/dev.conf") -> "conf/dev.conf" | |
| } | |
| mappings in Universal += { | |
| file("conf/prod.conf") -> "conf/prod.conf" | |
| } | |
| mappings in Universal += { | |
| file("conf/debian-logger.xml") -> "conf/debian-logger.xml" | |
| } | |
| mappings in Universal += { | |
| file("conf/mappings/portfolioMappings.csv") -> "conf/mappings/portfolioMappings.csv" | |
| } | |
| mappings in Universal += { | |
| file("scripts/importer-poststop.sh") -> "scripts/importer-poststop.sh" | |
| } | |
| // the bash scripts classpath only needs the fat jar | |
| scriptClasspath := Seq( (jarName in assembly).value ) | |
| maintainer in Linux := "xxx <xxx@example.com>" | |
| packageSummary := "xxx's importer" | |
| packageDescription := s"xxx's. $currentCommit" | |
| serverLoading in Debian := ServerLoader.Systemd | |
| daemonUser in Linux := (normalizedName in Debian).value | |
| daemonGroup in Linux := "xxx" | |
| debianPackageDependencies in Debian := "oracle-java8-jre (>= 1.8.0)" :: Nil | |
| defaultLinuxInstallLocation := "/opt" | |
| linuxStartScriptTemplate in Debian := (baseDirectory.value / "packaging" / "xxx-importer.service").asURL | |
| linuxScriptReplacements += "loader-functions" -> TemplateWriter.generateScript((baseDirectory.value / "packaging" / "custom-loader-functions").asURL, Nil) | |
| javaOptions in Universal ++= Seq( | |
| // Use separate configuration file for deploy environment | |
| s"-Dconfig.file=/opt/xxx-importer/conf/secrets.conf", | |
| // Use separate logger configuration file for deploy environment | |
| s"-Dlogback.configurationFile=/opt/xxx-importer/conf/debian-logger.xml" | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
it's just a simple question. Did you find any problem excluding
"joda-time"onphantom-dsl? I'd like to do the same.Thanks!