forked from playframework/playframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
501 lines (456 loc) · 18.8 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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
/*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
import BuildSettings._
import Dependencies._
import Generators._
import com.lightbend.sbt.javaagent.JavaAgent.JavaAgentKeys.javaAgents
import com.lightbend.sbt.javaagent.JavaAgent.JavaAgentKeys.resolvedJavaAgents
import interplay.PlayBuildBase.autoImport._
import pl.project13.scala.sbt.JmhPlugin.generateJmhSourcesAndResources
import sbt.Keys.parallelExecution
import sbt._
import sbt.io.Path._
import org.scalafmt.sbt.ScalafmtPlugin
// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
dynverVTagPrefix in ThisBuild := false
// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone)
// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version
Global / onLoad := (Global / onLoad).value.andThen { s =>
val v = version.value
if (dynverGitDescribeOutput.value.hasNoTags)
throw new MessageOnlyException(
s"Failed to derive version from git tags. Maybe run `git fetch --unshallow`? Version: $v"
)
s
}
lazy val BuildLinkProject = PlayNonCrossBuiltProject("Build-Link", "dev-mode/build-link")
.dependsOn(PlayExceptionsProject)
// run-support project is only compiled against sbt scala version
lazy val RunSupportProject = PlaySbtProject("Run-Support", "dev-mode/run-support")
.settings(
target := target.value / "run-support",
libraryDependencies ++= runSupportDependencies((sbtVersion in pluginCrossBuild).value)
)
.dependsOn(BuildLinkProject)
lazy val RoutesCompilerProject = PlayDevelopmentProject("Routes-Compiler", "dev-mode/routes-compiler")
.enablePlugins(SbtTwirl)
.settings(
libraryDependencies ++= routesCompilerDependencies(scalaVersion.value),
TwirlKeys.templateFormats := Map("twirl" -> "play.routes.compiler.ScalaFormat")
)
lazy val SbtRoutesCompilerProject = PlaySbtProject("Sbt-Routes-Compiler", "dev-mode/routes-compiler")
.enablePlugins(SbtTwirl)
.settings(
target := target.value / "sbt-routes-compiler",
libraryDependencies ++= routesCompilerDependencies(scalaVersion.value),
TwirlKeys.templateFormats := Map("twirl" -> "play.routes.compiler.ScalaFormat")
)
lazy val StreamsProject = PlayCrossBuiltProject("Play-Streams", "core/play-streams")
.settings(libraryDependencies ++= streamsDependencies)
lazy val PlayExceptionsProject = PlayNonCrossBuiltProject("Play-Exceptions", "core/play-exceptions")
lazy val PlayJodaFormsProject = PlayCrossBuiltProject("Play-Joda-Forms", "web/play-joda-forms")
.settings(
libraryDependencies ++= joda
)
.dependsOn(PlayProject, PlaySpecs2Project % "test")
lazy val PlayProject = PlayCrossBuiltProject("Play", "core/play")
.enablePlugins(SbtTwirl)
.settings(
libraryDependencies ++= runtime(scalaVersion.value) ++ scalacheckDependencies ++ cookieEncodingDependencies :+
jimfs % Test,
unmanagedSourceDirectories in Compile ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 => (sourceDirectory in Compile).value / s"java-scala-2.13+" :: Nil
case Some((2, v)) if v <= 12 => (sourceDirectory in Compile).value / s"java-scala-2.13-" :: Nil
case _ => Nil
}
},
sourceGenerators in Compile += Def
.task(
PlayVersion(
version.value,
scalaVersion.value,
sbtVersion.value,
jettyAlpnAgent.revision,
Dependencies.akkaVersion,
Dependencies.akkaHttpVersion,
(sourceManaged in Compile).value
)
)
.taskValue,
sourceDirectories in (Compile, TwirlKeys.compileTemplates) := (unmanagedSourceDirectories in Compile).value,
TwirlKeys.templateImports += "play.api.templates.PlayMagic._",
mappings in (Compile, packageSrc) ++= {
// Add both the templates, useful for end users to read, and the Scala sources that they get compiled to,
// so omnidoc can compile and produce scaladocs for them.
val twirlSources = (sources in (Compile, TwirlKeys.compileTemplates)).value
.pair(relativeTo((sourceDirectories in (Compile, TwirlKeys.compileTemplates)).value))
val twirlTarget = (target in (Compile, TwirlKeys.compileTemplates)).value
// The pair with errorIfNone being false both creates the mappings, and filters non twirl outputs out of
// managed sources
val twirlCompiledSources = (managedSources in Compile).value.pair(relativeTo(twirlTarget), errorIfNone = false)
twirlSources ++ twirlCompiledSources
},
Docs.apiDocsIncludeManaged := true
)
.settings(Docs.playdocSettings: _*)
.dependsOn(
BuildLinkProject,
StreamsProject
)
lazy val PlayServerProject = PlayCrossBuiltProject("Play-Server", "transport/server/play-server")
.settings(libraryDependencies ++= playServerDependencies)
.dependsOn(
PlayProject,
PlayGuiceProject % "test"
)
lazy val PlayNettyServerProject = PlayCrossBuiltProject("Play-Netty-Server", "transport/server/play-netty-server")
.settings(libraryDependencies ++= netty)
.dependsOn(PlayServerProject)
import AkkaDependency._
lazy val PlayAkkaHttpServerProject =
PlayCrossBuiltProject("Play-Akka-Http-Server", "transport/server/play-akka-http-server")
.dependsOn(PlayServerProject, StreamsProject)
.dependsOn(PlayGuiceProject % "test")
.settings(
libraryDependencies ++= specs2Deps.map(_ % "test")
)
.addAkkaModuleDependency("akka-http-core")
lazy val PlayAkkaHttp2SupportProject =
PlayCrossBuiltProject("Play-Akka-Http2-Support", "transport/server/play-akka-http2-support")
.dependsOn(PlayAkkaHttpServerProject)
.addAkkaModuleDependency("akka-http2-support")
lazy val PlayClusterSharding = PlayCrossBuiltProject("Play-Cluster-Sharding", "cluster/play-cluster-sharding")
.settings(libraryDependencies ++= clusterDependencies)
.dependsOn(PlayProject)
lazy val PlayJavaClusterSharding =
PlayCrossBuiltProject("Play-Java-Cluster-Sharding", "cluster/play-java-cluster-sharding")
.settings(libraryDependencies ++= clusterDependencies)
.dependsOn(PlayProject)
lazy val PlayJdbcApiProject = PlayCrossBuiltProject("Play-JDBC-Api", "persistence/play-jdbc-api")
.dependsOn(PlayProject)
lazy val PlayJdbcProject: Project = PlayCrossBuiltProject("Play-JDBC", "persistence/play-jdbc")
.settings(libraryDependencies ++= jdbcDeps)
.dependsOn(PlayJdbcApiProject)
.dependsOn(PlaySpecs2Project % "test")
lazy val PlayJdbcEvolutionsProject = PlayCrossBuiltProject("Play-JDBC-Evolutions", "persistence/play-jdbc-evolutions")
.settings(libraryDependencies += derbyDatabase % Test)
.dependsOn(PlayJdbcApiProject)
.dependsOn(PlaySpecs2Project % "test")
.dependsOn(PlayJdbcProject % "test->test")
.dependsOn(PlayJavaJdbcProject % "test")
lazy val PlayJavaJdbcProject = PlayCrossBuiltProject("Play-Java-JDBC", "persistence/play-java-jdbc")
.dependsOn(PlayJdbcProject % "compile->compile;test->test", PlayJavaProject)
.dependsOn(PlaySpecs2Project % "test", PlayGuiceProject % "test")
lazy val PlayJpaProject = PlayCrossBuiltProject("Play-Java-JPA", "persistence/play-java-jpa")
.settings(libraryDependencies ++= jpaDeps)
.dependsOn(PlayJavaJdbcProject % "compile->compile;test->test")
.dependsOn(PlayJdbcEvolutionsProject % "test")
.dependsOn(PlaySpecs2Project % "test")
lazy val PlayTestProject = PlayCrossBuiltProject("Play-Test", "testkit/play-test")
.settings(
libraryDependencies ++= testDependencies ++ Seq(h2database % "test"),
parallelExecution in Test := false
)
.dependsOn(
PlayGuiceProject,
PlayServerProject,
// We still need a server provider when running Play-Test tests.
// Since Akka HTTP is the default, we should use it here.
PlayAkkaHttpServerProject % "test"
)
lazy val PlaySpecs2Project = PlayCrossBuiltProject("Play-Specs2", "testkit/play-specs2")
.settings(
libraryDependencies ++= specs2Deps,
parallelExecution in Test := false
)
.dependsOn(PlayTestProject)
lazy val PlayJavaProject = PlayCrossBuiltProject("Play-Java", "core/play-java")
.settings(libraryDependencies ++= javaDeps ++ javaTestDeps)
.dependsOn(
PlayProject % "compile;test->test",
PlayTestProject % "test",
PlaySpecs2Project % "test",
PlayGuiceProject % "test"
)
lazy val PlayJavaFormsProject = PlayCrossBuiltProject("Play-Java-Forms", "web/play-java-forms")
.settings(
libraryDependencies ++= javaDeps ++ javaFormsDeps ++ javaTestDeps
)
.dependsOn(
PlayJavaProject % "compile;test->test"
)
lazy val PlayDocsProject = PlayCrossBuiltProject("Play-Docs", "dev-mode/play-docs")
.settings(Docs.settings: _*)
.settings(
libraryDependencies ++= playDocsDependencies
)
.dependsOn(PlayAkkaHttpServerProject)
lazy val PlayGuiceProject = PlayCrossBuiltProject("Play-Guice", "core/play-guice")
.settings(libraryDependencies ++= guiceDeps ++ specs2Deps.map(_ % "test"))
.dependsOn(
PlayProject % "compile;test->test"
)
lazy val SbtPluginProject = PlaySbtPluginProject("Sbt-Plugin", "dev-mode/sbt-plugin")
.enablePlugins(SbtPlugin)
.settings(
libraryDependencies ++= sbtDependencies((sbtVersion in pluginCrossBuild).value, scalaVersion.value),
sourceGenerators in Compile += Def.task {
PlayVersion(
version.value,
(scalaVersion in PlayProject).value,
sbtVersion.value,
jettyAlpnAgent.revision,
Dependencies.akkaVersion,
Dependencies.akkaHttpVersion,
(sourceManaged in Compile).value
)
}.taskValue,
headerSources in Compile ++= (sbtTestDirectory.value ** ("*.scala" || "*.java")).get,
)
.dependsOn(SbtRoutesCompilerProject, RunSupportProject)
lazy val SbtScriptedToolsProject = PlaySbtPluginProject("Sbt-Scripted-Tools", "dev-mode/sbt-scripted-tools")
.enablePlugins(SbtPlugin)
.dependsOn(SbtPluginProject)
.settings(disableNonLocalPublishing)
lazy val PlayLogback = PlayCrossBuiltProject("Play-Logback", "core/play-logback")
.settings(
libraryDependencies += logback,
parallelExecution in Test := false,
// quieten deprecation warnings in tests
scalacOptions in Test := (scalacOptions in Test).value.diff(Seq("-deprecation"))
)
.dependsOn(PlayProject)
.dependsOn(PlaySpecs2Project % "test")
lazy val PlayWsProject = PlayCrossBuiltProject("Play-WS", "transport/client/play-ws")
.settings(
libraryDependencies ++= playWsDeps,
parallelExecution in Test := false,
// quieten deprecation warnings in tests
scalacOptions in Test := (scalacOptions in Test).value.diff(Seq("-deprecation"))
)
.dependsOn(PlayProject)
.dependsOn(PlayTestProject % "test")
lazy val PlayAhcWsProject = PlayCrossBuiltProject("Play-AHC-WS", "transport/client/play-ahc-ws")
.settings(
libraryDependencies ++= playAhcWsDeps,
parallelExecution in Test := false,
// quieten deprecation warnings in tests
scalacOptions in Test := (scalacOptions in Test).value.diff(Seq("-deprecation"))
)
.dependsOn(PlayWsProject, PlayCaffeineCacheProject % "test")
.dependsOn(PlaySpecs2Project % "test")
.dependsOn(PlayTestProject % "test->test")
.dependsOn(PlayAkkaHttpServerProject % "test") // Because we need a server provider when running the tests
lazy val PlayOpenIdProject = PlayCrossBuiltProject("Play-OpenID", "web/play-openid")
.settings(
parallelExecution in Test := false,
// quieten deprecation warnings in tests
scalacOptions in Test := (scalacOptions in Test).value.diff(Seq("-deprecation"))
)
.dependsOn(PlayAhcWsProject)
.dependsOn(PlaySpecs2Project % "test")
lazy val PlayFiltersHelpersProject = PlayCrossBuiltProject("Filters-Helpers", "web/play-filters-helpers")
.settings(
libraryDependencies ++= playFilterDeps,
parallelExecution in Test := false
)
.dependsOn(
PlayProject,
PlayTestProject % "test",
PlayJavaProject % "test",
PlaySpecs2Project % "test",
PlayAhcWsProject % "test",
PlayAkkaHttpServerProject % "test" // Because we need a server provider when running the tests
)
lazy val PlayIntegrationTestProject = PlayCrossBuiltProject("Play-Integration-Test", "core/play-integration-test")
.enablePlugins(JavaAgent)
// This project is just for testing Play, not really a public artifact
.settings(disablePublishing)
.configs(IntegrationTest)
.settings(
Defaults.itSettings,
inConfig(IntegrationTest)(ScalafmtPlugin.scalafmtConfigSettings),
headerSettings(IntegrationTest),
inConfig(IntegrationTest)(JavaFormatterPlugin.toBeScopedSettings),
libraryDependencies += okHttp % IntegrationTest,
parallelExecution in IntegrationTest := false,
mimaPreviousArtifacts := Set.empty,
fork in IntegrationTest := true,
javaOptions in IntegrationTest += "-Dfile.encoding=UTF8",
javaAgents += jettyAlpnAgent % IntegrationTest,
javaOptions in IntegrationTest ++= {
val javaAgents = (resolvedJavaAgents in IntegrationTest).value
assert(javaAgents.length == 1, s"multiple java agents: $javaAgents")
val resolvedJavaAgent = javaAgents.head
val jettyAgentPath = resolvedJavaAgent.artifact.absString
Seq(
s"-Djetty.anlp.agent.jar=$jettyAgentPath",
"-javaagent:" + jettyAgentPath + resolvedJavaAgent.agent.arguments
)
}
)
.dependsOn(
PlayProject % "it->test",
PlayLogback % "it->test",
PlayAhcWsProject % "it->test",
PlayServerProject % "it->test",
PlaySpecs2Project
)
.dependsOn(PlayFiltersHelpersProject)
.dependsOn(PlayJavaProject)
.dependsOn(PlayJavaFormsProject)
.dependsOn(PlayAkkaHttpServerProject)
.dependsOn(PlayAkkaHttp2SupportProject)
.dependsOn(PlayNettyServerProject)
// NOTE: this project depends on JMH, which is GPLv2.
lazy val PlayMicrobenchmarkProject = PlayCrossBuiltProject("Play-Microbenchmark", "core/play-microbenchmark")
.enablePlugins(JmhPlugin, JavaAgent)
// This project is just for microbenchmarking Play. Not published.
.settings(disablePublishing)
.settings(
// Change settings so that IntelliJ can handle dependencies
// from JMH to the integration tests. We can't use "compile->test"
// when we depend on the integration test project, we have to use
// "test->test" so that IntelliJ can handle it. This means that
// we need to put our JMH sources into src/test so they can pick
// up the integration test files.
// See: https://github.com/ktoso/sbt-jmh/pull/73#issue-163891528
classDirectory in Jmh := (classDirectory in Test).value,
dependencyClasspath in Jmh := (dependencyClasspath in Test).value,
generateJmhSourcesAndResources in Jmh := (generateJmhSourcesAndResources in Jmh).dependsOn(compile in Test).value,
// Add the Jetty ALPN agent to the list of agents. This will cause the JAR to
// be downloaded and available. We need to tell JMH to use this agent when it
// forks its benchmark processes. We use a custom runner to read a system
// property and add the agent JAR to JMH's forked process JVM arguments.
javaAgents += jettyAlpnAgent,
javaOptions in (Jmh, run) += {
val javaAgents = (resolvedJavaAgents in Jmh).value
assert(javaAgents.length == 1)
val jettyAgentPath = javaAgents.head.artifact.absString
s"-Djetty.anlp.agent.jar=$jettyAgentPath"
},
mainClass in (Jmh, run) := Some("play.microbenchmark.PlayJmhRunner"),
parallelExecution in Test := false,
mimaPreviousArtifacts := Set.empty
)
.dependsOn(
PlayProject % "test->test",
PlayLogback % "test->test",
PlayIntegrationTestProject % "test->it",
PlayAhcWsProject,
PlaySpecs2Project,
PlayFiltersHelpersProject,
PlayJavaProject,
PlayNettyServerProject,
PlayAkkaHttpServerProject,
PlayAkkaHttp2SupportProject
)
lazy val PlayCacheProject = PlayCrossBuiltProject("Play-Cache", "cache/play-cache")
.settings(
libraryDependencies ++= playCacheDeps
)
.dependsOn(
PlayProject,
PlaySpecs2Project % "test"
)
lazy val PlayEhcacheProject = PlayCrossBuiltProject("Play-Ehcache", "cache/play-ehcache")
.settings(
libraryDependencies ++= playEhcacheDeps
)
.dependsOn(
PlayProject,
PlayCacheProject,
PlaySpecs2Project % "test"
)
lazy val PlayCaffeineCacheProject = PlayCrossBuiltProject("Play-Caffeine-Cache", "cache/play-caffeine-cache")
.settings(
libraryDependencies ++= playCaffeineDeps
)
.dependsOn(
PlayProject,
PlayCacheProject,
PlaySpecs2Project % "test"
)
// JSR 107 cache bindings (note this does not depend on ehcache)
lazy val PlayJCacheProject = PlayCrossBuiltProject("Play-JCache", "cache/play-jcache")
.settings(
libraryDependencies ++= jcacheApi
)
.dependsOn(
PlayProject,
PlayCaffeineCacheProject % "test", // provide a cachemanager implementation
PlaySpecs2Project % "test"
)
lazy val PlayDocsSbtPlugin = PlaySbtPluginProject("Play-Docs-Sbt-Plugin", "dev-mode/play-docs-sbt-plugin")
.enablePlugins(SbtPlugin)
.enablePlugins(SbtTwirl)
.settings(
libraryDependencies ++= playDocsSbtPluginDependencies,
scriptedDependencies := (()), // drop Test/compile & publishLocal being called on aggregating root scripted
)
.dependsOn(SbtPluginProject)
// These projects are aggregate by the root project and every
// task (compile, test, publish, etc) executed for the root
// project will also be executed for them:
// https://www.scala-sbt.org/1.x/docs/Multi-Project.html#Aggregation
//
// Keep in mind that specific configurations (like skip in publish) will be respected.
lazy val aggregatedProjects = Seq[ProjectReference](
PlayProject,
PlayGuiceProject,
BuildLinkProject,
RoutesCompilerProject,
SbtRoutesCompilerProject,
PlayAkkaHttpServerProject,
PlayAkkaHttp2SupportProject,
PlayCacheProject,
PlayEhcacheProject,
PlayCaffeineCacheProject,
PlayJCacheProject,
PlayJdbcApiProject,
PlayJdbcProject,
PlayJdbcEvolutionsProject,
PlayJavaProject,
PlayJavaFormsProject,
PlayJodaFormsProject,
PlayJavaJdbcProject,
PlayJpaProject,
PlayNettyServerProject,
PlayMicrobenchmarkProject,
PlayServerProject,
PlayLogback,
PlayWsProject,
PlayAhcWsProject,
PlayOpenIdProject,
RunSupportProject,
SbtPluginProject,
SbtScriptedToolsProject,
PlaySpecs2Project,
PlayTestProject,
PlayExceptionsProject,
PlayDocsProject,
PlayFiltersHelpersProject,
PlayIntegrationTestProject,
PlayDocsSbtPlugin,
StreamsProject,
PlayClusterSharding,
PlayJavaClusterSharding
)
lazy val PlayFramework = Project("Play-Framework", file("."))
.enablePlugins(PlayRootProject)
.enablePlugins(PlayWhitesourcePlugin)
.settings(
playCommonSettings,
scalaVersion := (scalaVersion in PlayProject).value,
playBuildRepoName in ThisBuild := "playframework",
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
libraryDependencies ++= (runtime(scalaVersion.value) ++ jdbcDeps),
Docs.apiDocsInclude := false,
Docs.apiDocsIncludeManaged := false,
mimaReportBinaryIssues := (()),
commands += Commands.quickPublish,
Release.settings
)
.aggregate(aggregatedProjects: _*)