forked from mdedetrich/scalajson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
162 lines (148 loc) · 5.04 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
162
name := "scalajson"
import PgpKeys.publishSigned
// shadow sbt-scalajs' crossProject and CrossType until Scala.js 1.0.0 is released
import sbtcrossproject.crossProject
val currentScalaVersion = "2.11.11"
val scala210Version = "2.10.6"
val scala212Version = "2.12.2"
val scalaCheckVersion = "1.13.4"
val specs2Version = "3.9.1"
scalaVersion in ThisBuild := currentScalaVersion
crossScalaVersions in ThisBuild := Seq(currentScalaVersion,
scala212Version,
scala210Version)
autoAPIMappings := true
val flagsFor10 = Seq(
"-Xlint",
"-Yclosure-elim",
"-Ydead-code"
)
val flagsFor11 = Seq(
"-Xlint:_",
"-Yconst-opt",
"-Ywarn-infer-any",
"-Yclosure-elim",
"-Ydead-code",
"-Xsource:2.12" // required to build case class construction
)
val flagsFor12 = Seq(
"-Xlint:_",
"-Ywarn-infer-any",
"-opt:l:project"
)
lazy val root = project
.in(file("."))
.aggregate(scalaJsonJS, scalaJsonJVM)
.settings(
publish := {},
publishLocal := {},
publishSigned := {}
)
lazy val commonSettings = Seq(
name := "scalajson",
version := "1.0.0-M4",
organization := "org.scala-lang.platform",
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-deprecation", // warning and location for usages of deprecated APIs
"-feature", // warning and location for usages of features that should be imported explicitly
"-unchecked", // additional warnings where generated code depends on assumptions
"-Xlint", // recommended additional warnings
"-Xcheckinit", // runtime error when a val is not initialized due to trait hierarchies (instead of NPE somewhere else)
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused
"-Ywarn-inaccessible",
"-Ywarn-dead-code"
),
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
pomIncludeRepository := (_ => false),
homepage := Some(url("https://github.com/mdedetrich/scalajson")),
scmInfo := Some(
ScmInfo(url("https://github.com/mdedetrich/scalajson"),
"[email protected]:mdedetrich/scalajson.git")),
developers := List(
Developer("mdedetrich",
"Matthew de Detrich",
url("https://github.com/mdedetrich"))
),
licenses += ("BSD 3 Clause", url(
"https://opensource.org/licenses/BSD-3-Clause"))
)
lazy val scalaJson = crossProject(JSPlatform, JVMPlatform)
.in(file("."))
.settings(
commonSettings,
// In our build, implementations are specific due to use using sealed traits so a build defined
// in scala-2.10 can't use the same sources as the generic 'scala' build. This removes the 'scala'
// directory from sources when building for Scala 2.10.x
(unmanagedSourceDirectories in Compile) := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 11 =>
(unmanagedSourceDirectories in Compile).value
case Some((2, n)) if n == 10 =>
(unmanagedSourceDirectories in Compile).value.filter { x =>
!x.getName.endsWith("scala")
}
}
},
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 =>
"-target:jvm-1.8"
case _ =>
"-target:jvm-1.6"
}
},
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 =>
flagsFor12
case Some((2, n)) if n == 11 =>
flagsFor11
case Some((2, n)) if n == 10 =>
flagsFor10
}
}
)
.jvmSettings(
// Add JVM-specific settings here
libraryDependencies ++= Seq(
"org.specs2" %% "specs2-core" % specs2Version % Test,
"org.specs2" %% "specs2-scalacheck" % specs2Version % Test,
"org.scalacheck" %% "scalacheck" % scalaCheckVersion % Test
),
scalacOptions in Test ++= Seq("-Yrangepos"),
mimaPreviousArtifacts := Set(
"org.scala-lang.platform" %% "scalajson" % "1.0.0-M3")
)
.jsSettings(
// Add JS-specific settings here
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test,
"com.lihaoyi" %%% "utest" % "0.4.4" % Test
),
testFrameworks += new TestFramework("utest.runner.Framework")
)
lazy val benchmark = crossProject(JSPlatform, JVMPlatform)
.in(file("benchmark"))
.jvmSettings(
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"),
libraryDependencies ++= Seq(
"com.storm-enroute" %% "scalameter" % "0.8.2" % Test
)
)
.dependsOn(scalaJson)
lazy val scalaJsonJVMTest = benchmark.jvm
lazy val scalaJsonJSTest = benchmark.js
lazy val scalaJsonJVM = scalaJson.jvm
lazy val scalaJsonJS = scalaJson.js