-
Notifications
You must be signed in to change notification settings - Fork 702
/
build.sbt
192 lines (174 loc) · 5.82 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
import build._
val minSuccessfulTests = settingKey[Int]("")
/*
* NOTICE if you are a contributor who only cares about the JVM, create a file
* `local.sbt` containing
*
* Global / onLoad := { s => "project rootJVM" :: s }
*
* and regular commands such as "compile" / "test" will skip over all the
* scalajs / scala-native stuff.
*/
lazy val jsProjects = Seq[ProjectReference](
coreJS, effectJS, iterateeJS, scalacheckBindingJS, testsJS, exampleJS
)
lazy val jvmProjects = Seq[ProjectReference](
coreJVM, effectJVM, iterateeJVM, scalacheckBindingJVM, testsJVM, exampleJVM
)
lazy val nativeProjects = Seq[ProjectReference](
coreNative, effectNative, iterateeNative, scalacheckBindingNative, testsNative, exampleNative
)
lazy val scalaz = Project(
id = "scalaz",
base = file(".")
).settings(
standardSettings,
description := "scalaz unidoc",
artifacts := Classpaths.artifactDefs(Seq(Compile / packageDoc, Compile / makePom)).value,
packagedArtifacts := Classpaths.packaged(Seq(Compile / packageDoc, Compile / makePom)).value,
pomPostProcess := { node =>
import scala.xml._
import scala.xml.transform._
val rule = new RewriteRule {
override def transform(n: Node) =
if (n.label == "dependencies") NodeSeq.Empty else n
}
new RuleTransformer(rule).transform(node)(0)
},
ScalaUnidoc / unidoc / unidocProjectFilter := {
(jsProjects ++ nativeProjects).foldLeft(inAnyProject)((acc, a) => acc -- inProjects(a))
},
Defaults.packageTaskSettings(Compile / packageDoc, (Compile / unidoc).map(_.flatMap(Path.allSubpaths)))
).aggregate(
jvmProjects ++ jsProjects ++ nativeProjects : _*
).enablePlugins(ScalaUnidocPlugin)
lazy val rootNative = Project(
"rootNative",
file("rootNative")
).settings(
standardSettings,
notPublish
).aggregate(nativeProjects: _*)
lazy val rootJS = Project(
"rootJS",
file("rootJS")
).settings(
standardSettings,
notPublish
).aggregate(jsProjects: _*)
lazy val rootJVM = Project(
"rootJVM",
file("rootJVM")
).settings(
standardSettings,
notPublish
).aggregate(jvmProjects: _*)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val coreNative = core.native
lazy val effectJVM = effect.jvm
lazy val effectJS = effect.js
lazy val effectNative = effect.native
lazy val iterateeJVM = iteratee.jvm
lazy val iterateeJS = iteratee.js
lazy val iterateeNative = iteratee.native
lazy val exampleJVM = example.jvm
lazy val exampleJS = example.js
lazy val exampleNative = example.native
lazy val example = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(ScalazCrossType)
.in(file("example"))
.settings(
standardSettings,
unmanagedSourcePathSettings,
name := "scalaz-example",
notPublish,
Compile / compile / scalacOptions -= "-Xlint:adapted-args",
)
.jvmSettings(
TaskKey[Unit]("runAllMain") := {
val r = (run / runner).value
val classpath = (Compile / fullClasspath).value
val log = streams.value.log
(Compile / discoveredMainClasses).value.sorted.foreach(c =>
r.run(c, classpath.map(_.data), Nil, log)
)
},
)
.jsSettings(
scalajsProjectSettings,
scalaJSUseMainModuleInitializer := true,
commands += Command.command("runAllMain") { state1 =>
val extracted = Project.extract(state1)
val (state2, classes) = extracted.runTask(Compile / discoveredMainClasses, state1)
classes.sorted.flatMap(c => s"""set Compile / mainClass := Some("$c")""" :: "run" :: Nil).toList ::: state2
},
)
.nativeSettings(
commands += Command.command("runAllMain") { state1 =>
val extracted = Project.extract(state1)
val (state2, classes) = extracted.runTask(Compile / discoveredMainClasses, state1)
classes.sorted.flatMap(c => s"""set Compile / selectMainClass := Some("$c")""" :: "run" :: Nil).toList ::: state2
},
).dependsOn(
core, iteratee
)
lazy val scalacheckBinding =
crossProject(JVMPlatform, JSPlatform, NativePlatform).crossType(ScalazCrossType)
.in(file("scalacheck-binding"))
.settings(standardSettings)
.settings(
unmanagedSourcePathSettings,
name := "scalaz-scalacheck-binding",
Compile / compile / scalacOptions -= "-Ywarn-value-discard",
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.18.1",
)
.dependsOn(core, iteratee)
.jsSettings(scalajsProjectSettings)
lazy val scalacheckBindingJVM = scalacheckBinding.jvm
lazy val scalacheckBindingJS = scalacheckBinding.js
lazy val scalacheckBindingNative = scalacheckBinding.native
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform).crossType(ScalazCrossType)
.settings(standardSettings)
.settings(
unmanagedSourcePathSettings,
name := "scalaz-tests",
notPublish,
(Test / testOptions) += {
val scalacheckOptions = Seq(
"-maxSize", "5",
"-workers", "1",
"-maxDiscardRatio", "50",
"-minSuccessfulTests", minSuccessfulTests.value.toString
)
Tests.Argument(TestFrameworks.ScalaCheck, scalacheckOptions: _*)
},
(Test / sources) := {
val exclude = Set(
"LeibnizTest.scala",
"MonadErrorTest.scala",
"UnapplyTest.scala",
)
val list = (Test / sources).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
list.filterNot { src =>
exclude.contains(src.getName)
}
case _ =>
list
}
},
)
.platformsSettings(JVMPlatform, NativePlatform)(
minSuccessfulTests := 33,
)
.jsSettings(
minSuccessfulTests := 10,
libraryDependencies += ("org.scala-js" %%% "scalajs-weakreferences" % "1.0.0" % Test).cross(CrossVersion.for3Use2_13)
)
.dependsOn(core, effect, iteratee, scalacheckBinding)
.jsSettings(scalajsProjectSettings)
lazy val testsJVM = tests.jvm
lazy val testsJS = tests.js
lazy val testsNative = tests.native