-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.sbt
201 lines (184 loc) · 6.24 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
import sbtrelease._
import com.typesafe.tools.mima.core._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossType
import ReleaseTransformations._
val Scala211 = "2.11.12"
val NativeCond = s"matrix.scala == '$Scala211'"
ThisBuild / crossScalaVersions := Seq(Scala211, "2.12.15", "2.13.5")
ThisBuild / scalaVersion := Scala211
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowBuildPreamble +=
WorkflowStep.Run(
List("sudo apt install clang libunwind-dev libgc-dev libre2-dev"),
name = Some("Setup scala native dependencies"),
cond = Some(NativeCond))
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List("test", "test:doc", "mimaReportBinaryIssues"),
name = Some("Run main build")),
WorkflowStep.Sbt(
List("coreNative/test", "examplesNative/test"),
name = Some("Run native build"),
cond = Some(NativeCond)))
val scalatestVersion = "3.2.9"
lazy val nativeCommonSettings = Def.settings(
scalaVersion := Scala211,
crossScalaVersions := Seq(Scala211),
nativeLinkStubs := true
)
lazy val commonSettings = Seq(
organization := "org.typelevel",
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-language:higherKinds",
"-language:implicitConversions"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
Seq("-Ymacro-annotations")
case _ =>
Nil
}
},
Compile / doc / scalacOptions ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
Compile / console / scalacOptions ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)
case _ =>
// if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect
// https://github.com/scala/scala/pull/6606
Nil
}
},
licenses += ("Three-clause BSD-style", url("https://github.com/mpilquist/simulacrum/blob/master/LICENSE")),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { x => false },
pomExtra := (
<url>http://github.com/mpilquist/simulacrum</url>
<scm>
<url>git@github.com:mpilquist/simulacrum.git</url>
<connection>scm:git:git@github.com:mpilquist/simulacrum.git</connection>
</scm>
<developers>
<developer>
<id>mpilquist</id>
<name>Michael Pilquist</name>
<url>http://github.com/mpilquist</url>
</developer>
</developers>
),
pomPostProcess := { node =>
import scala.xml._
import scala.xml.transform._
def stripIf(f: Node => Boolean) = new RewriteRule {
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf { n => n.label == "dependency" && (n \ "scope").text == "test" }
new RuleTransformer(stripTestScope).transform(node)(0)
},
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
releaseStepCommandAndRemaining("test:doc"),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
releaseStepCommandAndRemaining(s";++${Scala211}!;coreNative/publish"),
setNextVersion,
commitNextVersion,
pushChanges
),
Test / compile / wartremoverErrors ++= Seq(
Wart.ExplicitImplicitTypes,
Wart.ImplicitConversion)
)
lazy val root = project.in(file("."))
.settings(commonSettings: _*)
.settings(crossScalaVersions := Seq(Scala211))
.settings(noPublishSettings: _*)
.aggregate(coreJVM, examplesJVM, coreJS, examplesJS)
ThisBuild / mimaFailOnNoPrevious := false
def previousVersion(scalaVersion: String, currentVersion: String): Option[String] = {
if (scalaVersion == "2.13.0")
None
else {
val Version = """(\d+)\.(\d+)\.(\d+).*""".r
val Version(x, y, z) = currentVersion
if (z == "0") None
else Some(s"$x.$y.${z.toInt - 1}")
}
}
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform).crossType(CrossType.Pure)
.settings(commonSettings: _*)
.settings(
moduleName := "simulacrum",
Test / scalacOptions += "-Yno-imports"
)
.settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.scalatest" %%% "scalatest" % scalatestVersion % "test"
)
)
.nativeSettings(
nativeCommonSettings
)
.platformsSettings(JSPlatform, NativePlatform)(
Test / unmanagedSources / excludeFilter := "jvm.scala"
)
.jvmSettings(
mimaPreviousArtifacts := previousVersion(scalaVersion.value, version.value).map { pv =>
organization.value % ("simulacrum" + "_" + scalaBinaryVersion.value) % pv
}.toSet
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val coreNative = core.native
lazy val examples = crossProject(JSPlatform, JVMPlatform, NativePlatform).crossType(CrossType.Pure)
.dependsOn(core % "provided")
.settings(commonSettings: _*)
.settings(moduleName := "simulacrum-examples")
.settings(
libraryDependencies += "org.scalatest" %%% "scalatest" % scalatestVersion % "test"
)
.settings(noPublishSettings: _*)
.platformsSettings(JVMPlatform, JSPlatform)(
libraryDependencies += "com.chuusai" %%% "shapeless" % "2.3.7" % "test"
)
.nativeSettings(
nativeCommonSettings
)
lazy val examplesJVM = examples.jvm
lazy val examplesJS = examples.js
lazy val examplesNative = examples.native
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)