SentinelBuild.scala 6.83 KB
Newer Older
bow's avatar
bow committed
1
2
3
import sbt._
import Keys._
import org.scalatra.sbt._
4
import com.atlassian.labs.gitstamp.GitStampPlugin._
5
import com.earldouglas.xwp.XwpPlugin._
6
import com.typesafe.sbt.SbtScalariform._
7
import com.typesafe.sbt.SbtSite.site
bow's avatar
bow committed
8
import de.heikoseeberger.sbtheader._
bow's avatar
bow committed
9
import sbtassembly.{ AssemblyKeys, MergeStrategy, PathList }, AssemblyKeys._
bow's avatar
bow committed
10
11

object SentinelBuild extends Build {
12

bow's avatar
bow committed
13
14
15
16
  val Organization = "nl.lumc.sasc"
  val Name = "Sentinel"
  val Version = "0.1.0-SNAPSHOT"
  val ScalaVersion = "2.11.6"
17
  val JavaVersion = "1.8"
bow's avatar
bow committed
18
  val ScalatraVersion = "2.3.1"
bow's avatar
bow committed
19
  val Json4sVersion = "3.2.11"
20
21
  val JettyVersion = "9.2.10.v20150310"
  val JettyRunnerModule = "org.eclipse.jetty" % "jetty-runner" % JettyVersion % "container"
bow's avatar
bow committed
22

bow's avatar
bow committed
23
24
25
26
  lazy val dependencies = Seq(
    "ch.qos.logback"          %  "logback-classic"            % "1.1.2"               % "runtime",
    "com.github.fge"          %  "json-schema-validator"      % "2.2.6",
    "com.novus"               %% "salat"                      % "1.9.9",
27
    "com.typesafe"            %  "config"                     % "1.3.0",
bow's avatar
bow committed
28
29
30
31
    "com.typesafe.akka"       %% "akka-actor"                 % "2.3.6",
    "commons-codec"           %  "commons-codec"              % "1.7",
    "commons-io"              %  "commons-io"                 % "2.4",
    "de.flapdoodle.embed"     %  "de.flapdoodle.embed.mongo"  % "1.47.3"              % "test;it",
bow's avatar
bow committed
32
    "javax.servlet"           %  "javax.servlet-api"          % "3.1.0"               % "container;compile;provided;test;it",
bow's avatar
bow committed
33
34
35
    "net.databinder.dispatch" %% "dispatch-core"              % "0.11.2",
    "net.databinder.dispatch" %% "dispatch-json4s-jackson"    % "0.11.2",
    "org.eclipse.jetty"       %  "jetty-plus"                 % JettyVersion          % "container",
bow's avatar
bow committed
36
    "org.eclipse.jetty"       %  "jetty-webapp"               % JettyVersion          % "container;compile",
bow's avatar
bow committed
37
38
39
40
41
42
43
44
45
46
47
48
    "org.json4s"              %% "json4s-jackson"             % Json4sVersion,
    "org.json4s"              %% "json4s-mongo"               % Json4sVersion,
    "org.json4s"              %% "json4s-ext"                 % Json4sVersion,
    "org.mongodb"             %% "casbah"                     % "2.8.0",
    "org.mindrot"             %  "jbcrypt"                    % "0.3m",
    "org.scalatra"            %% "scalatra"                   % ScalatraVersion,
    "org.scalatra"            %% "scalatra-specs2"            % ScalatraVersion       % "test;it",
    "org.scalatra"            %% "scalatra-json"              % ScalatraVersion,
    "org.scalatra"            %% "scalatra-swagger"           % ScalatraVersion,
    "org.scalatra"            %% "scalatra-swagger-ext"       % ScalatraVersion,
    "org.scalatra"            %% "scalatra-slf4j"             % ScalatraVersion)

bow's avatar
bow committed
49
50
51
52
53
54
55
  lazy val formattingPreferences = {
    import scalariform.formatter.preferences._
    FormattingPreferences()
      .setPreference(AlignParameters, true)
      .setPreference(AlignSingleLineCaseStatements, true)
      .setPreference(CompactStringConcatenation, false)
      .setPreference(CompactControlReadability, false)
56
      .setPreference(DoubleIndentClassDeclaration, true)
bow's avatar
bow committed
57
58
59
      .setPreference(IndentLocalDefs, false)
      .setPreference(IndentPackageBlocks, true)
      .setPreference(IndentSpaces, 2)
60
      .setPreference(IndentWithTabs, false)
bow's avatar
bow committed
61
62
63
64
65
66
67
68
69
70
      .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, false)
      .setPreference(PreserveDanglingCloseParenthesis, true)
      .setPreference(PreserveSpaceBeforeArguments, false)
      .setPreference(RewriteArrowSymbols, false)
      .setPreference(SpaceBeforeColon, false)
      .setPreference(SpaceInsideBrackets, false)
      .setPreference(SpaceInsideParentheses, false)
      .setPreference(SpacesWithinPatternBinders, true)
  }

bow's avatar
bow committed
71
72
73
  lazy val headerSettings = Seq(HeaderPlugin.autoImport.headers := Map(
    "scala" -> (
      HeaderPattern.cStyleBlockComment,
bow's avatar
bow committed
74
      """|/*
bow's avatar
bow committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
        | * Copyright (c) 2015 Leiden University Medical Center and contributors
        | *                    (see AUTHORS.md file for details).
        | *
        | * Licensed under the Apache License, Version 2.0 (the "License");
        | * you may not use this file except in compliance with the License.
        | * You may obtain a copy of the License at
        | *
        | * http://www.apache.org/licenses/LICENSE-2.0
        | *
        | * Unless required by applicable law or agreed to in writing, software
        | * distributed under the License is distributed on an "AS IS" BASIS,
        | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        | * See the License for the specific language governing permissions and
        | * limitations under the License.
        | */
        |""".stripMargin
bow's avatar
bow committed
91
      ))) ++ AutomateHeaderPlugin.automateFor(IntegrationTest)
bow's avatar
bow committed
92

bow's avatar
bow committed
93
  lazy val jettyRunnerSettings = jetty(Seq(JettyRunnerModule))
94

bow's avatar
bow committed
95
  lazy val projectSettings = ScalatraPlugin.scalatraWithJRebel ++ scalariformSettings ++ jettyRunnerSettings ++
96
97
    site.settings ++ site.sphinxSupport() ++ site.includeScaladoc() ++ headerSettings ++ Defaults.itSettings ++
    gitStampSettings ++ Seq(
bow's avatar
bow committed
98
99
100
101
102
103
104
105
106
107
108
109
      organization := Organization,
      name := Name,
      version := Version,
      initialize := {
        val _ = initialize.value
        if (sys.props("java.specification.version") != JavaVersion)
          sys.error("Sentinel requires Java 8.")
      },
      scalaVersion := ScalaVersion,
      scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
      testOptions in Test += Tests.Argument("console", "junitxml"),
      testOptions in IntegrationTest += Tests.Argument("console", "junitxml"),
bow's avatar
bow committed
110
111
112
113
114
115
116
117
118
119
      mainClass in assembly := Some("nl.lumc.sasc.sentinel.JettyLauncher"),
      test in assembly := {
        (test in Test).value
        (test in IntegrationTest).value
      },
      assemblyMergeStrategy in assembly := {
        // TODO: track down conflicting dependency for this library ~ for now it seems safe to take the first one
        case PathList("org", "apache", "commons", "collections", xs @ _*) => MergeStrategy.first
        case otherwise => (assemblyMergeStrategy in assembly).value(otherwise)
      },
bow's avatar
bow committed
120
      assemblyJarName in assembly := Name + "-" + Version + ".jar",
bow's avatar
bow committed
121
122
      ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
      resolvers += Classpaths.typesafeReleases,
bow's avatar
bow committed
123
      resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
bow's avatar
bow committed
124
125
126
127
      resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
      resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/",
      ScalariformKeys.preferences := formattingPreferences,
      dependencyOverrides ++= Set(JettyRunnerModule),
bow's avatar
bow committed
128
      libraryDependencies ++= dependencies)
129

bow's avatar
bow committed
130
131
  lazy val project = Project("sentinel",  file("."))
    .enablePlugins(AutomateHeaderPlugin)
132
    .configs(IntegrationTest)
bow's avatar
bow committed
133
    .settings(projectSettings)
bow's avatar
bow committed
134
}