forked from UKHomeOffice/drt-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
147 lines (130 loc) · 5.71 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
import sbt.Keys._
import sbt.Project.projectToRef
scalaVersion := Settings.versions.scala
resolvers ++= Seq(
Resolver.bintrayRepo("mfglabs", "maven"),
Resolver.bintrayRepo("dwhjames", "maven")
)
// a special crossProject for configuring a JS/JVM/shared structure
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared"))
.settings(
scalaVersion := Settings.versions.scala,
libraryDependencies ++= Settings.sharedDependencies.value
)
// set up settings specific to the JS project
.jsConfigure(_ enablePlugins ScalaJSPlay)
val bundle = project.in(file("bundle"))
addCommandAlias("bundle", "bundle/bundle")
lazy val sharedJVM = shared.jvm.settings(name := "sharedJVM")
lazy val sharedJS = shared.js.settings(name := "sharedJS")
// use eliding to drop some debug code in the production build
lazy val elideOptions = settingKey[Seq[String]]("Set limit for elidable functions")
// instantiate the JS project for SBT with some additional settings
lazy val client: Project = (project in file("client"))
.settings(
name := "client",
version := Settings.version,
scalaVersion := Settings.versions.scala,
scalacOptions ++= Settings.scalacOptions,
libraryDependencies ++= Settings.scalajsDependencies.value,
// by default we do development build, no eliding
elideOptions := Seq(),
scalacOptions ++= elideOptions.value,
jsDependencies ++= Settings.jsDependencies.value,
// RuntimeDOM is needed for tests
jsDependencies += RuntimeDOM % "test",
jsDependencies += ProvidedJS / "bundle.js",
// yes, we want to package JS dependencies
skip in packageJSDependencies := false,
// use Scala.js provided launcher code to start the client app
persistLauncher := true,
persistLauncher in Test := false,
resolvers += Resolver.sonatypeRepo("snapshots"),
resolvers += "release" at "https://artifactory.digital.homeoffice.gov.uk/artifactory/libs-release-local",
resolvers += Resolver.defaultLocal,
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
// use uTest framework for tests
testFrameworks += new TestFramework("utest.runner.Framework")
)
.enablePlugins(ScalaJSPlugin, ScalaJSPlay)
.dependsOn(sharedJS)
// Client projects (just one in this case)
lazy val clients = Seq(client)
lazy val serverMacros = (project in file("server-macros"))
.settings(
name := "drtmacros",
version := Settings.version,
scalaVersion := Settings.versions.scala,
scalacOptions ++= Settings.scalacOptions,
libraryDependencies ++= Settings.jvmDependencies.value,
commands += ReleaseCmd,
// connect to the client project
scalaJSProjects := clients,
pipelineStages := Seq(scalaJSProd, digest, gzip),
testFrameworks += new TestFramework("utest.runner.Framework"),
resolvers += Resolver.bintrayRepo("mfglabs", "maven"),
resolvers += Resolver.bintrayRepo("dwhjames", "maven"),
resolvers += "BeDataDriven" at "https://nexus.bedatadriven.com/content/groups/public",
resolvers += "release" at "https://artifactory.digital.homeoffice.gov.uk/artifactory/libs-release-local",
resolvers += Resolver.defaultLocal,
publishArtifact in(Compile, packageBin) := false,
// Disable scaladoc generation for this project (useless)
publishArtifact in(Compile, packageDoc) := false,
// Disable source jar for this project (useless)
publishArtifact in(Compile, packageSrc) := false,
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
// compress CSS
LessKeys.compress in Assets := true
)
.enablePlugins(PlayScala)
.disablePlugins(PlayLayoutPlugin) // use the standard directory layout instead of Play's custom
.aggregate(clients.map(projectToRef): _*)
.dependsOn(sharedJVM)
// instantiate the JVM project for SBT with some additional settings
lazy val server = (project in file("server"))
.settings(
name := "drt",
version := Settings.version,
scalaVersion := Settings.versions.scala,
scalacOptions ++= Settings.scalacOptions,
libraryDependencies ++= Settings.jvmDependencies.value,
commands += ReleaseCmd,
// connect to the client project
scalaJSProjects := clients,
pipelineStages := Seq(scalaJSProd, digest, gzip),
testFrameworks += new TestFramework("utest.runner.Framework"),
resolvers += "BeDataDriven" at "https://nexus.bedatadriven.com/content/groups/public",
resolvers += "release" at "https://artifactory.digital.homeoffice.gov.uk/artifactory/libs-release-local",
resolvers += Resolver.defaultLocal,
publishArtifact in(Compile, packageBin) := false,
// Disable scaladoc generation for this project (useless)
publishArtifact in(Compile, packageDoc) := false,
// Disable source jar for this project (useless)
publishArtifact in(Compile, packageSrc) := false,
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
// compress CSS
LessKeys.compress in Assets := true,
PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
)
)
.enablePlugins(PlayScala)
.disablePlugins(PlayLayoutPlugin) // use the standard directory layout instead of Play's custom
.aggregate(clients.map(projectToRef): _*)
.dependsOn(sharedJVM, serverMacros)
// Command for building a release
lazy val ReleaseCmd = Command.command("release") {
state =>
"set elideOptions in client := Seq(\"-Xelide-below\", \"WARNING\")" ::
"client/clean" ::
"client/test" ::
"server/clean" ::
"server/test" ::
"server/dist" ::
"set elideOptions in client := Seq()" ::
state
}
fork in run := true
fork in Test := true
// loads the Play server project at sbt startup
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value