-
Notifications
You must be signed in to change notification settings - Fork 570
Expand file tree
/
Copy pathbuild.sbt
More file actions
281 lines (258 loc) · 6.98 KB
/
Copy pathbuild.sbt
File metadata and controls
281 lines (258 loc) · 6.98 KB
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
import play.sbt.routes.RoutesKeys
import com.typesafe.sbt.web.SbtWeb.autoImport._
import com.typesafe.sbt.packager.archetypes.JavaAppPackaging.autoImport._
import com.gu.Dependencies._
import com.gu.ProjectSettings._
/*
We need to set a wide width here because otherwise the output from
the `dependencyTree` command can get truncated, especially for nested projects.
The output from `dependencyTree` is used by Snyk to monitor our dependencies.
If the output is truncated, Snyk might report false positives.
See
https://support.snyk.io/hc/en-us/articles/9590215676189-Deeply-nested-Scala-projects-have-dependencies-truncated
*/
ThisBuild / asciiGraphWidth := 999999999
ThisBuild / scalaVersion := SCALA_VERSION
val templateTrackerJar = "template-tracker-agent.jar"
/*
* Standalone JVM agent that records which Twirl templates are rendered at runtime.
*
* This is a pure java project that uses ByteBuddy to instrument the Twirl template classes at runtime
* It is self-contained and any dependency is shadded to avoid any dependency conflict.
*
* The output of this module is a JAR file that gets attached to any service that requires this instrumentation
*/
val templateTrackerAgent = Project("template-tracker-agent", file("template-tracker-agent"))
.settings(
crossPaths := false, // pure Java: don't append a _2.13 suffix to the artifact
autoScalaLibrary := false, // pure Java: no scala-library dependency
libraryDependencies += byteBuddy,
assembly / assemblyJarName := templateTrackerJar,
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("net.bytebuddy.**" -> "com.gu.shaded.bytebuddy.@1").inAll,
),
assembly / packageOptions += Package.ManifestAttributes(
"Premain-Class" -> "com.gu.templatetracker.TemplateTrackerAgent",
"Can-Redefine-Classes" -> "true",
"Can-Retransform-Classes" -> "true",
),
)
val withTwirlInstrumentation: Seq[SettingsDefinition] = Seq(
Universal / mappings += {
val agentJar = (templateTrackerAgent / assembly).value
agentJar -> s"agent/${templateTrackerJar}"
},
bashScriptExtraDefines += s"""addJava "-javaagent:$${app_home}/../agent/${templateTrackerJar}"""",
)
val common = library("common")
.settings(
libraryDependencies ++= Seq(
apacheCommonsLang,
awsCloudwatch,
awsDynamodb,
awsKinesis,
awsS3,
awsSns,
awsSts,
awsSqs,
awsSsm,
eTagCachingS3,
contentApiClient,
contentApiModelsJson,
enumeratumPlayJson,
filters,
commonsLang,
jodaConvert,
jodaTime,
jSoup,
json4s,
panDomainAuth,
editorialPermissions,
quartzScheduler,
redisClient,
rome,
romeModules,
scalaCheck,
scalaCollectionPlus,
nScalaTime,
ws,
faciaFapiScalaClient,
closureCompiler,
jerseyCore,
jerseyClient,
cssParser,
w3cSac,
logstash,
targetingClient,
scanamo,
scalaUri,
commercialShared,
playJson,
playJsonJoda,
jodaForms,
identityModel,
capiAws,
pekkoActor,
pekkoStream,
pekkoSlf4j,
pekkoSerializationJackson,
pekkoActorTyped,
supportInternationalisation,
) ++ jackson,
)
val commonWithTests = withTests(common)
val facia = application("facia")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(
libraryDependencies += scalaCheck,
)
.settings(withTwirlInstrumentation: _*)
val article = application("article")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val applications = application("applications")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val archive = application("archive")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val sport = application("sport")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(
libraryDependencies ++= Seq(
paClient,
),
)
.settings(withTwirlInstrumentation: _*)
val discussion = application("discussion")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val admin = application("admin")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(
libraryDependencies ++= Seq(
paClient,
bootstrap,
jquery,
jqueryui,
lodash,
react,
epoch,
d3,
awsElasticloadbalancing,
awsSes,
scalaUri,
),
RoutesKeys.routesImport += "bindables._",
RoutesKeys.routesImport += "org.joda.time.LocalDate",
)
.settings(withTwirlInstrumentation: _*)
val faciaPress = application("facia-press")
.dependsOn(commonWithTests)
.settings(
libraryDependencies ++= Seq(
awsKinesis,
),
)
.settings(withTwirlInstrumentation: _*)
val identity = application("identity")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(
libraryDependencies ++= Seq(
filters,
identityAuthCore,
slf4jExt,
libPhoneNumber,
supportInternationalisation,
),
PlayKeys.playDefaultPort := 9009,
Test / testOptions += Tests.Argument("-oF"),
)
.settings(withTwirlInstrumentation: _*)
val commercial = application("commercial")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val onward = application("onward")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val dev = application("dev-build")
.dependsOn(
withTests(article),
)
.dependsOn(
facia,
applications,
archive,
sport,
discussion,
identity,
admin,
commercial,
onward,
)
.settings(
RoutesKeys.routesImport += "bindables._",
Runtime / javaOptions += "-Dconfig.file=dev-build/conf/dev-build.application.conf",
)
val preview = application("preview")
.dependsOn(
commonWithTests,
article,
facia,
applications,
sport,
commercial,
onward,
)
.settings(withTwirlInstrumentation: _*)
val rss = application("rss")
.dependsOn(commonWithTests)
.aggregate(common)
.settings(withTwirlInstrumentation: _*)
val main = root()
.aggregate(
common,
facia,
faciaPress,
article,
applications,
sport,
discussion,
admin,
identity,
commercial,
onward,
archive,
preview,
rss,
)
val badgeHash = inputKey[Unit]("Generate special badge salts and hashes")
badgeHash := {
import java.math.BigInteger
import java.security.MessageDigest
import complete.DefaultParsers._
import java.util.UUID
val result = spaceDelimited("<arg>").parsed.headOption
.map { tag =>
val salt = UUID.randomUUID.toString.replaceAll("-", "")
val saltedTag = salt + tag
val digest = MessageDigest.getInstance("MD5")
digest.update(saltedTag.getBytes(), 0, saltedTag.length)
val hash = new BigInteger(1, digest.digest()).toString(16)
s"salt=$salt\nhash=$hash"
}
.getOrElse {
"error: expected tag parameter"
}
println(result)
}