forked from johnynek/unuhi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
215 lines (198 loc) · 6.98 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import ReleaseTransformations._
import sbtcrossproject.{crossProject, CrossType}
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
lazy val catsVersion = "1.3.0"
lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publishArtifact := false)
lazy val unuhiSettings = Seq(
organization := "org.bykn",
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.11.12", "2.12.6", "2.13.0-M4"),
version := "0.1.0-SNAPSHOT",
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) =>
val xs0 = if (n <= 12) List("-Xfatal-warnings", "-Yno-adapted-args") else Nil
val xs1 = if (n >= 12) List("-Ypartial-unification") else Nil
val xs2 = if (n >= 11) List("-Ywarn-numeric-widen") else Nil
xs0 ::: xs1 ::: xs2
case _ =>
Nil
}),
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xlint",
"-Ywarn-dead-code",
"-Ywarn-value-discard",
"-Xfuture"),
// HACK: without these lines, the console is basically unusable,
// since all imports are reported as being unused (and then become
// fatal errors).
scalacOptions in (Compile, console) ~= {_.filterNot("-Xlint" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
// release stuff
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges),
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")
},
pomExtra := (
<url>https://github.com/bykn/unuhi</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<url>[email protected]:bykn/unuhi.git</url>
<connection>scm:git:[email protected]:bykn/unuhi.git</connection>
</scm>
<developers>
<developer>
<id>johnynek</id>
<name>Oscar Boykin</name>
<url>http://github.com/johnynek/</url>
</developer>
</developers>
),
coverageMinimum := 60,
coverageFailOnMinimum := false) ++ mimaDefaultSettings
def previousArtifact(version: String, proj: String) = {
// the "-dbuild..." part is for Scala community build friendliness
val regex = "0\\.([0-9]+)\\.[0-9]+(-SNAPSHOT|-dbuild[a-z0-9]*)?".r
version match {
case regex("1", _) => Set("org.bykn" %% s"unuhi-$proj" % "0.1.0")
case regex("2", _) => Set.empty[ModuleID]
case _ => throw new RuntimeException(s"Unexpected version: ${version}")
}
}
lazy val commonJvmSettings = Seq(
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"))
lazy val commonJsSettings = Seq(
scalaJSStage in Global := FastOptStage,
parallelExecution := false,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
// batch mode decreases the amount of memory needed to compile scala.js code
scalaJSOptimizerOptions := scalaJSOptimizerOptions.value.withBatchMode(scala.sys.env.get("TRAVIS").isDefined))
lazy val unuhi = project
.in(file("."))
.settings(name := "root")
.settings(unuhiSettings: _*)
.settings(noPublish: _*)
.aggregate(unuhiJVM, unuhiJS)
.dependsOn(unuhiJVM, unuhiJS)
lazy val unuhiJVM = project
.in(file(".unuhiJVM"))
.settings(moduleName := "unuhi")
.settings(unuhiSettings)
.settings(commonJvmSettings)
.aggregate(coreJVM)
.dependsOn(coreJVM)
lazy val unuhiJS = project
.in(file(".unuhiJS"))
.settings(moduleName := "unuhi")
.settings(unuhiSettings)
.settings(commonJsSettings)
.aggregate(coreJS)
.dependsOn(coreJS)
.enablePlugins(ScalaJSPlugin)
lazy val core = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.in(file("core"))
.settings(name := "unuhi-core")
.settings(moduleName := "unuhi-core")
.settings(unuhiSettings: _*)
//.settings(mimaPreviousArtifacts := previousArtifact(version.value, "core"))
.disablePlugins(JmhPlugin)
.jsSettings(commonJsSettings:_*)
.jsSettings(coverageEnabled := false)
.jvmSettings(commonJvmSettings:_*)
.platformsSettings(JVMPlatform, JSPlatform)(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsVersion,
"org.scalacheck" %%% "scalacheck" % "1.13.4" % Test,
"org.scalatest" %%% "scalatest" % "3.0.5" % Test
)
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val laws = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.in(file("laws"))
.settings(name := "unuhi-laws")
.settings(moduleName := "unuhi-laws")
.settings(unuhiSettings: _*)
//.settings(mimaPreviousArtifacts := previousArtifact(version.value, "laws"))
.disablePlugins(JmhPlugin)
.jsSettings(commonJsSettings:_*)
.jsSettings(coverageEnabled := false)
.jvmSettings(commonJvmSettings:_*)
.platformsSettings(JVMPlatform, JSPlatform)(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsVersion,
"org.typelevel" %%% "cats-laws" % catsVersion,
"org.typelevel" %%% "cats-testkit" % catsVersion,
"org.scalacheck" %%% "scalacheck" % "1.13.4" % Test,
"org.scalatest" %%% "scalatest" % "3.0.5" % Test
)
)
.dependsOn(core)
lazy val lawsJVM = laws.jvm
lazy val lawsJS = laws.js
lazy val fastparse = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.in(file("fastparse"))
.settings(name := "unuhi-fastparse")
.settings(moduleName := "unuhi-fastparse")
.settings(unuhiSettings: _*)
//.settings(mimaPreviousArtifacts := previousArtifact(version.value, "fastparse"))
.disablePlugins(JmhPlugin)
.jsSettings(commonJsSettings:_*)
.jsSettings(coverageEnabled := false)
.jvmSettings(commonJvmSettings:_*)
.platformsSettings(JVMPlatform, JSPlatform)(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsVersion,
"com.lihaoyi" %%% "fastparse" % "1.0.0",
"org.scalacheck" %%% "scalacheck" % "1.13.4" % Test,
"org.scalatest" %%% "scalatest" % "3.0.5" % Test
)
)
.dependsOn(core)
lazy val fastparseJVM = fastparse.jvm
lazy val fastparseJS = fastparse.js
lazy val bench = project.in(file("bench"))
.dependsOn(coreJVM, fastparseJVM)
.settings(name := "unuhi-benchmark")
.settings(unuhiSettings: _*)
.settings(noPublish: _*)
.settings(coverageEnabled := false)
.enablePlugins(JmhPlugin)