-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sbt
179 lines (164 loc) · 5.81 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name := "scalajson"
import PgpKeys.publishSigned
// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x
import sbtcrossproject.CrossPlugin.autoImport.{ crossProject, CrossType }
val currentScalaVersion = "2.11.12"
val scala210Version = "2.10.7"
val scala212Version = "2.12.8"
val scala213Version = "2.13.0"
val scalaCheckVersion = "1.14.0"
val scalaTestVersion = "3.0.8"
scalaVersion in ThisBuild := currentScalaVersion
crossScalaVersions in ThisBuild := Seq(currentScalaVersion,
scala213Version,
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-inline-from:<sources>",
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
"-Ywarn-inaccessible"
)
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-value-discard", // Warn when non-Unit expression results are unused
"-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, NativePlatform)
.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 >= 13 =>
Nil
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.scalatest" %% "scalatest" % scalaTestVersion % 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.scalatest" %%% "scalatest" % scalaTestVersion % Test,
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test
),
testFrameworks += TestFrameworks.ScalaTest,
scalacOptions in Test ++= Seq("-Yrangepos")
)
.nativeSettings(
crossScalaVersions := Seq(currentScalaVersion)
)
lazy val scalameterVersion = settingKey[String]("version of ScalaMeter dependency")
scalameterVersion in ThisBuild := (CrossVersion.partialVersion(scalaVersion.value) match {
// this snapshot is the only thing available for 2.13.0-M3 at present
case Some ((2, n)) if n == 13 => "0.10-SNAPSHOT"
case _ => "0.8.2"
})
lazy val benchmark = crossProject(JSPlatform, JVMPlatform)
.in(file("benchmark"))
.jvmSettings(
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"),
// need snapshot resolver because ScalaMeter is only available for 2.13.0-M3 as a snapshot
resolvers += Resolver.sonatypeRepo("snapshots"),
libraryDependencies ++= Seq(
"com.storm-enroute" %% "scalameter" % scalameterVersion.value % Test
)
)
.dependsOn(scalaJson)
lazy val scalaJsonJVMTest = benchmark.jvm
lazy val scalaJsonJSTest = benchmark.js
lazy val scalaJsonJVM = scalaJson.jvm
lazy val scalaJsonJS = scalaJson.js
lazy val scalaJsonNative = scalaJson.native