/
build.sbt
161 lines (116 loc) · 6.25 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
organization := "tv.cntt"
name := "xitrum"
scalaVersion := "2.11.6" // "2.10.5"
crossScalaVersions := Seq("2.11.6", "2.10.5")
// Run sbt mima-report-binary-issues to check for binary compatibility ---------
// http://www.typesafe.com/community/core-tools/migration-manager
version := "3.24.1-SNAPSHOT"
com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact := Some("tv.cntt" % ("xitrum_" + scalaBinaryVersion.value) % "3.23")
//------------------------------------------------------------------------------
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked")
// xitrum.util.FileMonitor requires Java 7
javacOptions ++= Seq("-source", "1.7", "-target", "1.7")
// Source code for Scala 2.10 and 2.11 are a little different ------------------
// See src/main/scala-2.10 and src/main/scala-2.11.
unmanagedSourceDirectories in Compile += baseDirectory.value / "src" / "main" / s"scala-${scalaBinaryVersion.value}"
//------------------------------------------------------------------------------
// Projects using Xitrum must provide a concrete implementation of SLF4J (Logback etc.)
libraryDependencies += "org.slf4s" %% "slf4s-api" % "1.7.10"
// Netty is the core of Xitrum's HTTP(S) feature
libraryDependencies += "io.netty" % "netty-all" % "4.0.28.Final"
// http://netty.io/wiki/forked-tomcat-native.html
// Include all classifiers for convenience
libraryDependencies += "io.netty" % "netty-tcnative" % "1.1.33.Fork2" classifier "linux-x86_64"
libraryDependencies += "io.netty" % "netty-tcnative" % "1.1.33.Fork2" classifier "osx-x86_64"
libraryDependencies += "io.netty" % "netty-tcnative" % "1.1.33.Fork2" classifier "windows-x86_64"
// Javassist boosts Netty 4 speed
libraryDependencies += "org.javassist" % "javassist" % "3.19.0-GA"
// Redirect Akka log to SLF4J
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.11"
libraryDependencies += "com.typesafe.akka" %% "akka-cluster" % "2.3.11"
libraryDependencies += "com.typesafe.akka" %% "akka-contrib" % "2.3.11"
libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.3.11"
// For clustering SockJS with Akka
libraryDependencies += "tv.cntt" %% "glokka" % "2.3"
// For file watch
// (akka-agent is added here, should ensure same Akka version as above)
libraryDependencies += "com.beachape.filemanagement" %% "schwatcher" % "0.1.8"
// For scanning routes
libraryDependencies += "tv.cntt" %% "sclasner" % "1.7.0"
// For binary (de)serializing
libraryDependencies += "com.twitter" %% "chill" % "0.6.0"
// For JSON (de)serializing
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.2.11"
// For i18n
libraryDependencies += "tv.cntt" %% "scaposer" % "1.5"
// For jsEscape
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.4"
// For compiling CoffeeScript to JavaScript
libraryDependencies += "tv.cntt" % "rhinocoffeescript" % "1.9.2"
// For metrics
libraryDependencies += "nl.grons" %% "metrics-scala" % "3.5.1_a2.3"
// For metrics
libraryDependencies += "io.dropwizard.metrics" % "metrics-json" % "3.1.2"
// JSON4S uses scalap 2.10.0/2.11.0, which in turn uses scala-compiler 2.10.0/2.11.0, which in
// turn uses scala-reflect 2.10.0/2.11.0. We need to force "scalaVersion" above, because
// Scala annotations (used by routes and Swagger) compiled by a newer version
// can't be read by an older version.
//
// Also, we must release a new version of Xitrum every time a new version of
// Scala is released.
libraryDependencies <+= scalaVersion { sv => "org.scala-lang" % "scalap" % sv }
// WebJars ---------------------------------------------------------------------
libraryDependencies += "org.webjars" % "jquery" % "2.1.4"
libraryDependencies += "org.webjars" % "jquery-validation" % "1.13.1"
libraryDependencies += "org.webjars" % "sockjs-client" % "1.0.0"
libraryDependencies += "org.webjars" % "swagger-ui" % "2.0.24"
libraryDependencies += "org.webjars" % "d3js" % "3.5.5-1"
// For test --------------------------------------------------------------------
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test"
// An implementation of SLF4J is needed for log in tests to be output
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3" % "test"
// For "sbt console"
unmanagedClasspath in Compile <+= (baseDirectory) map { bd => Attributed.blank(bd / "src/test/resources") }
// For "sbt run/test"
unmanagedClasspath in Runtime <+= (baseDirectory) map { bd => Attributed.blank(bd / "src/test/resources") }
// Generate src/main/scala/xitrum/Version.scala from "version" above -----------
val generateVersionFileTask = TaskKey[Unit]("generateVersion", "Generate src/main/scala/xitrum/Version.scala")
generateVersionFileTask <<= generateVersionFile
(compile in Compile) <<= (compile in Compile) dependsOn (generateVersionFile)
def generateVersionFile = Def.task {
val versions = version.value.split('.')
val major = versions(0).toInt
val minor = versions(1).toInt
val patch = versions(2).split('-')(0).toInt
val ma_mi_pa = s"$major.$minor.$patch"
val base = (baseDirectory in Compile).value
// Also check if the directory name is correct
val resDir = base / s"src/main/resources/META-INF/resources/webjars/xitrum/$ma_mi_pa"
if (!resDir.exists) throw new Exception(s"Directory name incorrect: $resDir")
// Do not overwrite version file if its content doesn't change
val file = base / "src/main/scala/xitrum/Version.scala"
val content = s"""// Autogenerated by build.sbt. Do not modify this file directly.
package xitrum
class Version {
val major = $major
val minor = $minor
val patch = $patch
/** major.minor.patch: $ma_mi_pa */
override def toString = "$ma_mi_pa"
}
"""
if (!file.exists) {
IO.write(file, content)
} else {
val oldContent = IO.read(file)
if (content != oldContent) IO.write(file, content)
}
}
//------------------------------------------------------------------------------
// Avoid messy Scaladoc by excluding things that are not intended to be used
// directly by normal Xitrum users.
scalacOptions in (Compile, doc) ++= Seq("-skip-packages", "xitrum.sockjs")
// Skip API doc generation to speedup "publish-local" while developing.
// Comment out this line when publishing to Sonatype.
publishArtifact in (Compile, packageDoc) := false