forked from frees-io/freestyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
411 lines (363 loc) · 11.3 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
import sbtorgpolicies.runnable.syntax._
lazy val root = (project in file("."))
.settings(moduleName := "root")
.settings(name := "freestyle")
.settings(noPublishSettings: _*)
.aggregate(allModules: _*)
lazy val core = module("core")
.jsSettings(sharedJsSettings: _*)
.settings(libraryDependencies ++= Seq(%("scala-reflect", scalaVersion.value)))
.settings(
wartremoverWarnings in (Test, compile) := Warts.unsafe,
wartremoverWarnings in (Test, compile) ++= Seq(Wart.FinalCaseClass, Wart.ExplicitImplicitTypes),
wartremoverWarnings in (Test, compile) -= Wart.NonUnitStatements
)
.crossDepSettings(
commonDeps ++ Seq(
%("cats-free"),
%("iota-core"),
%("simulacrum"),
%("shapeless") % "test",
%("cats-laws") % "test",
%%("mainecoon-core")
): _*
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val tests = jvmModule("tests")
.dependsOn(coreJVM % "compile->compile;test->test")
.settings(noPublishSettings: _*)
.settings(
libraryDependencies ++= commonDeps ++ Seq(
%("scala-reflect", scalaVersion.value),
%%("pcplod") % "test",
%%("monix-eval") % "test"
),
fork in Test := true,
javaOptions in Test ++= {
val excludedScalacOptions: List[String] = List("-Yliteral-types")
val options = (scalacOptions in Test).value.distinct
.filterNot(excludedScalacOptions.contains)
.mkString(",")
val cp = (fullClasspath in Test).value.map(_.data).filter(_.exists()).distinct.mkString(",")
Seq(
s"""-Dpcplod.settings=$options""",
s"""-Dpcplod.classpath=$cp"""
)
}
)
lazy val bench = jvmModule("bench")
.dependsOn(jvmFreestyleDeps: _*)
.settings(
name := "bench",
description := "freestyle benchmark"
)
.enablePlugins(JmhPlugin)
.configs(Codegen)
.settings(inConfig(Codegen)(Defaults.configSettings))
.settings(classpathConfiguration in Codegen := Compile)
.settings(noPublishSettings)
.settings(libraryDependencies ++= Seq(%%("cats-free"), %%("scalacheck")))
.settings(inConfig(Compile)(
sourceGenerators += Def.task {
val path = (sourceManaged in (Compile, compile)).value / "bench.scala"
(runner in (Codegen, run)).value.run(
"freestyle.free.bench.BenchBoiler",
Attributed.data((fullClasspath in Codegen).value),
path.toString :: Nil,
streams.value.log)
path :: Nil
}
))
lazy val Codegen = sbt.config("codegen").hide
lazy val effects = module("effects")
.dependsOn(core)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps ++ Seq(%("cats-mtl-core")): _*)
lazy val effectsJVM = effects.jvm
lazy val effectsJS = effects.js
lazy val async = module("async", subFolder = Some("async"))
.dependsOn(core)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps ++ Seq(%("cats-effect") % Test): _*)
lazy val asyncJVM = async.jvm
lazy val asyncJS = async.js
lazy val asyncCatsEffect = module("async-cats-effect", subFolder = Some("async"))
.dependsOn(core, async)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps ++ Seq(%("cats-effect")): _*)
lazy val asyncCatsEffectJVM = asyncCatsEffect.jvm
lazy val asyncCatsEffectJS = asyncCatsEffect.js
lazy val asyncGuava = jvmModule("async-guava", subFolder = Some("async"))
.dependsOn(coreJVM, asyncJVM)
.settings(libraryDependencies ++= commonDeps ++ Seq(%("guava")))
lazy val cache = module("cache")
.dependsOn(core)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps: _*)
lazy val cacheJVM = cache.jvm
lazy val cacheJS = cache.js
lazy val config = jvmModule("config")
.dependsOn(coreJVM)
.settings(
fixResources := {
val testConf = (resourceDirectory in Test).value / "application.conf"
val targetFile = (classDirectory in (coreJVM, Compile)).value / "application.conf"
if (testConf.exists) {
IO.copyFile(
testConf,
targetFile
)
}
},
compile in Test := ((compile in Test) dependsOn fixResources).value
)
.settings(
libraryDependencies ++= Seq(
%("config"),
%%("classy-config-typesafe"),
%%("classy-core")
) ++ commonDeps
)
lazy val logging = module("logging")
.dependsOn(core)
.jvmSettings(
libraryDependencies ++= Seq(
%%("journal-core"),
%%("log4s")
)
)
.jsSettings(
libraryDependencies += %%%("slogging")
)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps ++ Seq(%%("sourcecode")): _*)
lazy val loggingJVM = logging.jvm
lazy val loggingJS = logging.js
//////////////////////
//// INTEGRATIONS ////
//////////////////////
lazy val monix = module("monix", full = false, subFolder = Some("integrations"))
.dependsOn(core)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(commonDeps ++
Seq(%("monix-eval")): _*)
lazy val monixJVM = monix.jvm
lazy val monixJS = monix.js
lazy val cacheRedis = jvmModule("cache-redis", subFolder = Some("integrations"))
.dependsOn(coreJVM, cacheJVM)
.settings(
resolvers += "Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases/",
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
%%("rediscala"),
%%("akka-actor") % "test",
%("embedded-redis") % "test"
) ++ commonDeps
)
lazy val doobie = jvmModule("doobie", subFolder = Some("integrations"))
.dependsOn(coreJVM)
.settings(
libraryDependencies ++= Seq(
%%("doobie-core"),
%%("doobie-h2") % "test"
) ++ commonDeps
)
lazy val slick = jvmModule("slick", subFolder = Some("integrations"))
.dependsOn(coreJVM, asyncJVM)
.settings(
libraryDependencies ++= Seq(
%%("slick"),
%("h2") % "test"
) ++ commonDeps
)
lazy val twitterUtil = jvmModule("twitter-util", subFolder = Some("integrations"))
.dependsOn(coreJVM)
.settings(
libraryDependencies ++= Seq(%%("catbird-util")) ++ commonDeps
)
lazy val fetch = module("fetch", subFolder = Some("integrations"))
.dependsOn(core)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(
commonDeps ++ Seq(%("fetch")): _*
)
lazy val fetchJVM = fetch.jvm
lazy val fetchJS = fetch.js
/////////////////////////////
//// INTEGRATIONS - HTTP ////
/////////////////////////////
lazy val httpHttp4s = jvmModule("http4s", subFolder = Some("integrations/http"))
.dependsOn(coreJVM)
.settings(
libraryDependencies ++= Seq(
%%("http4s-core"),
%%("http4s-dsl") % "test"
) ++ commonDeps
)
lazy val httpFinch = jvmModule("finch", subFolder = Some("integrations/http"))
.dependsOn(coreJVM)
.settings(
libraryDependencies ++= Seq(%%("finch-core")) ++ commonDeps
)
lazy val httpAkka = jvmModule("akka", subFolder = Some("integrations/http"))
.dependsOn(coreJVM)
.settings(
libraryDependencies ++= Seq(
%%("akka-http"),
%%("akka-http-testkit") % "test"
) ++ commonDeps
)
lazy val httpPlay = jvmModule("play", subFolder = Some("integrations/http"))
.dependsOn(coreJVM)
.settings(
concurrentRestrictions in Global := Seq(Tags.limitAll(1)),
libraryDependencies ++= Seq(
%%("play") % "test",
%%("play-test") % "test"
) ++ commonDeps
)
lazy val httpClient = module("http-client", subFolder = Some("integrations/http"))
.dependsOn(core)
.settings(resolvers += Resolver.jcenterRepo)
.jsSettings(sharedJsSettings: _*)
.crossDepSettings(
commonDeps ++ Seq(%("hammock-core"), %("cats-effect") % "test"): _*
)
lazy val httpClientJS = httpClient.js
lazy val httpClientJVM = httpClient.jvm
//////////////////
//// EXAMPLES ////
//////////////////
lazy val `todolist-lib` = jvmModule("todolist-lib", subFolder = Some("examples"))
.dependsOn(coreJVM, doobie, loggingJVM, effectsJVM)
.settings(
libraryDependencies ++= Seq(
%%("cats-effect"),
%%("doobie-h2"),
%%("doobie-hikari")
) ++ commonDeps
)
lazy val `todolist-http-finch` = jvmModule("todolist-http-finch", subFolder = Some("examples"))
.dependsOn(`todolist-lib`, httpFinch, config, asyncCatsEffectJVM)
.settings(noPublishSettings: _*)
.settings(
libraryDependencies ++= Seq(
%%("circe-generic"),
%%("finch-circe"),
%%("twitter-server")
) ++ commonDeps
)
lazy val `todolist-http-http4s` = jvmModule("todolist-http-http4s", subFolder = Some("examples"))
.dependsOn(`todolist-lib`, httpHttp4s, config)
.settings(noPublishSettings: _*)
.settings(
libraryDependencies ++= Seq(
%%("http4s-dsl"),
%%("circe-generic"),
%%("http4s-circe"),
%%("http4s-blaze-server")
) ++ commonDeps
)
lazy val slickExample = jvmModule("slick-example", subFolder = Some("examples"))
.dependsOn(coreJVM, loggingJVM, slick)
.settings(noPublishSettings: _*)
.settings(slickGen := slickCodeGenTask.value) // register manual sbt command
.settings(
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "42.1.1",
"com.typesafe.slick" %% "slick-codegen" % "3.2.0"
) ++ commonDeps
)
/////////////////////
//// ALL MODULES ////
/////////////////////
lazy val jvmModules: Seq[ProjectReference] = Seq(
coreJVM,
effectsJVM,
asyncJVM,
asyncCatsEffectJVM,
asyncGuava,
cacheJVM,
config,
loggingJVM,
//Integrations:
monixJVM,
cacheRedis,
doobie,
slick,
twitterUtil,
fetchJVM,
httpHttp4s,
httpFinch,
httpAkka,
httpPlay,
httpClientJVM,
//tests,
//Examples:
`todolist-lib`,
`todolist-http-finch`,
`todolist-http-http4s`,
slickExample
)
lazy val jsModules: Seq[ProjectReference] = Seq(
coreJS,
effectsJS,
asyncJS,
asyncCatsEffectJS,
cacheJS,
loggingJS,
//Integrations:
monixJS,
fetchJS,
httpClientJS
)
lazy val allModules: Seq[ProjectReference] = jvmModules ++ jsModules
lazy val jvmFreestyleDeps: Seq[ClasspathDependency] =
jvmModules.map(ClasspathDependency(_, None))
addCommandAlias("validateDocs", ";project docs;tut;project root")
addCommandAlias(
"validateJVM",
(List("fixResources") ++ toCompileTestList(jvmModules) ++ List("project root")).asCmd)
addCommandAlias("validateJS", (toCompileTestList(jsModules) ++ List("project root")).asCmd)
addCommandAlias(
"validate",
";clean;compile;coverage;validateJVM;coverageReport;coverageAggregate;coverageOff")
///////////////
//// DOCS ////
///////////////
lazy val docs = (project in file("docs"))
.dependsOn(jvmFreestyleDeps: _*)
.settings(moduleName := "frees-docs")
.settings(micrositeSettings: _*)
.settings(noPublishSettings: _*)
.settings(
addCompilerPlugin(%%("scalameta-paradise") cross CrossVersion.full),
libraryDependencies += %%("scalameta", "1.8.0"),
scalacOptions += "-Xplugin-require:macroparadise"
)
.settings(
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.bintrayRepo("kailuowang", "maven"),
Resolver.bintrayRepo("tabdulradi", "maven")
),
libraryDependencies ++= Seq(
%%("monix"),
%%("doobie-h2"),
%%("http4s-dsl"),
%%("play"),
%("h2") % "test"
)
)
.settings(
scalacOptions in Tut ~= (_ filterNot Set("-Ywarn-unused-import", "-Xlint").contains)
)
.settings(
micrositeGithubToken := getEnvVar(orgGithubTokenSetting.value)
)
.enablePlugins(MicrositesPlugin)
.disablePlugins(ProjectPlugin)
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")