This repository was archived by the owner on Jan 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
139 lines (125 loc) · 5.71 KB
/
build.sbt
File metadata and controls
139 lines (125 loc) · 5.71 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
import java.util.Properties
val Scalaversion = "2.12.7"
val Scalatraversion = "2.6.5"
val ScalaLoggingVersion = "3.9.0"
val ScalaTestVersion = "3.0.5"
val Log4JVersion = "2.11.1"
val Jettyversion = "9.4.18.v20190429"
val AwsSdkversion = "1.11.434"
val MockitoVersion = "2.23.0"
val Elastic4sVersion = "6.3.7"
val JacksonVersion = "2.9.9.3"
val ElasticsearchVersion = "6.3.2"
val Json4SVersion = "3.5.4"
val CatsEffectVersion = "1.0.0"
val FlywayVersion = "5.2.0"
val PostgresVersion = "42.2.5"
val HikariConnectionPoolVersion = "3.2.0"
val appProperties = settingKey[Properties]("The application properties")
appProperties := {
val prop = new Properties()
IO.load(prop, new File("build.properties"))
prop
}
lazy val listing_api = (project in file("."))
.settings(
name := "listing-api",
organization := appProperties.value.getProperty("NDLAOrganization"),
version := appProperties.value.getProperty("NDLAComponentVersion"),
scalaVersion := Scalaversion,
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions := Seq("-target:jvm-1.8", "-deprecation"),
libraryDependencies ++= Seq(
"ndla" %% "network" % "0.42",
"ndla" %% "mapping" % "0.14",
"com.typesafe.scala-logging" %% "scala-logging" % ScalaLoggingVersion,
"org.apache.logging.log4j" % "log4j-api" % Log4JVersion,
"org.apache.logging.log4j" % "log4j-core" % Log4JVersion,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % Log4JVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % JacksonVersion,
"joda-time" % "joda-time" % "2.10",
"org.scalatra" %% "scalatra" % Scalatraversion,
"org.scalatra" %% "scalatra-json" % Scalatraversion,
"org.scalatra" %% "scalatra-swagger" % Scalatraversion,
"org.scalatra" %% "scalatra-scalatest" % Scalatraversion % "test",
"org.eclipse.jetty" % "jetty-webapp" % Jettyversion % "container;compile",
"org.eclipse.jetty" % "jetty-plus" % Jettyversion % "container",
"org.json4s" %% "json4s-native" % Json4SVersion,
"org.scalikejdbc" %% "scalikejdbc" % "3.3.1",
"org.postgresql" % "postgresql" % PostgresVersion,
"com.zaxxer" % "HikariCP" % HikariConnectionPoolVersion,
"org.flywaydb" % "flyway-core" % FlywayVersion,
"io.lemonlabs" %% "scala-uri" % "1.3.1",
"org.scalatest" %% "scalatest" % ScalaTestVersion % "test",
"org.mockito" % "mockito-core" % MockitoVersion % "test",
"org.elasticsearch" % "elasticsearch" % ElasticsearchVersion,
"com.sksamuel.elastic4s" %% "elastic4s-core" % Elastic4sVersion,
"com.sksamuel.elastic4s" %% "elastic4s-http" % Elastic4sVersion,
"com.sksamuel.elastic4s" %% "elastic4s-aws" % Elastic4sVersion,
"com.sksamuel.elastic4s" %% "elastic4s-embedded" % Elastic4sVersion % "test",
"com.fasterxml.jackson.core" % "jackson-databind" % JacksonVersion, // Overriding jackson-databind used in dependencies because of https://app.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-72884
"org.elasticsearch" % "elasticsearch" % ElasticsearchVersion % "test",
"org.jsoup" % "jsoup" % "1.11.3",
"log4j" % "log4j" % "1.2.16",
"net.bull.javamelody" % "javamelody-core" % "1.74.0",
"org.jrobin" % "jrobin" % "1.5.9",
"com.amazonaws" % "aws-java-sdk-cloudwatch" % AwsSdkversion
)
)
.enablePlugins(DockerPlugin)
.enablePlugins(JettyPlugin)
assembly / assemblyJarName := "listing-api.jar"
assembly / mainClass := Some("no.ndla.listingapi.JettyLauncher")
assembly / assemblyMergeStrategy := {
case "mime.types" => MergeStrategy.filterDistinctLines
case PathList("org", "joda", "convert", "ToString.class") =>
MergeStrategy.first
case PathList("org", "joda", "convert", "FromString.class") =>
MergeStrategy.first
case PathList("org", "joda", "time", "base", "BaseDateTime.class") =>
MergeStrategy.first
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
val checkfmt = taskKey[Boolean]("check for code style errors")
checkfmt := {
val noErrorsInMainFiles = (Compile / scalafmtCheck).value
val noErrorsInTestFiles = (Test / scalafmtCheck).value
val noErrorsInBuildFiles = (Compile / scalafmtSbtCheck).value
noErrorsInMainFiles && noErrorsInTestFiles && noErrorsInBuildFiles
}
Test / test := (Test / test).dependsOn(Test / checkfmt).value
val fmt = taskKey[Unit]("Automatically apply code style fixes")
fmt := {
(Compile / scalafmt).value
(Test / scalafmt).value
(Compile / scalafmtSbt).value
}
// Don't run Integration tests in default run on Travis as there is no elasticsearch localhost:9200 there yet.
// NB this line will unfortunalty override runs on your local commandline so that
// sbt "test-only -- -n no.ndla.tag.IntegrationTest"
// will not run unless this line gets commented out or you remove the tag over the test class
// This should be solved better!
Test / testOptions += Tests.Argument("-l", "no.ndla.tag.IntegrationTest")
// Make the docker task depend on the assembly task, which generates a fat JAR file
docker := (docker dependsOn assembly).value
docker / dockerfile := {
val artifact = (assembly / assemblyOutputPath).value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("adoptopenjdk/openjdk11:alpine-slim")
run("apk", "--no-cache", "add", "ttf-dejavu")
add(artifact, artifactTargetPath)
entryPoint("java", "-Dorg.scalatra.environment=production", "-jar", artifactTargetPath)
}
}
docker / imageNames := Seq(
ImageName(namespace = Some(organization.value),
repository = name.value,
tag = Some(System.getProperty("docker.tag", "SNAPSHOT")))
)
resolvers ++= scala.util.Properties
.envOrNone("NDLA_RELEASES")
.map(repo => "Release Sonatype Nexus Repository Manager" at repo)
.toSeq