forked from NDLANO/image-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
128 lines (114 loc) · 5.7 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
import java.util.Properties
val Scalaversion = "2.12.2"
val Scalatraversion = "2.5.1"
val ScalaLoggingVersion = "3.7.2"
val Log4JVersion = "2.9.1"
val Jettyversion = "9.2.10.v20150310"
val AwsSdkversion = "1.11.318"
val ScalaTestVersion = "3.0.1"
val MockitoVersion = "1.10.19"
val Elastic4sVersion = "6.1.4"
val ElasticsearchVersion = "6.0.1"
val appProperties = settingKey[Properties]("The application properties")
appProperties := {
val prop = new Properties()
IO.load(prop, new File("build.properties"))
prop
}
lazy val commonSettings = Seq(
organization := appProperties.value.getProperty("GDLOrganization"),
version := appProperties.value.getProperty("GDLComponentVersion"),
scalaVersion := Scalaversion
)
lazy val image_api = (project in file(".")).
settings(commonSettings: _*).
settings(
name := "image-api",
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions := Seq("-target:jvm-1.8", "-unchecked", "-deprecation", "-feature"),
libraryDependencies ++= Seq(
"gdl" %% "network" % "0.12",
"ndla" %% "mapping" % "0.8",
"gdl" %% "language" % "0.10",
"gdl" %% "license" % "0.2",
"joda-time" % "joda-time" % "2.8.2",
"org.scalatra" %% "scalatra" % Scalatraversion,
"org.scalatra" %% "scalatra-json" % Scalatraversion,
"org.scalatra" %% "scalatra-swagger" % Scalatraversion,
"org.scalatra" %% "scalatra-scalatest" % Scalatraversion % "test",
"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,
"org.eclipse.jetty" % "jetty-webapp" % Jettyversion % "container;compile",
"org.eclipse.jetty" % "jetty-plus" % Jettyversion % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "container;provided;test",
"org.json4s" %% "json4s-native" % "3.5.0",
"org.scalikejdbc" %% "scalikejdbc" % "3.2.1",
"org.postgresql" % "postgresql" % "42.2.1",
"com.zaxxer" % "HikariCP" % "2.7.8",
"mysql" % "mysql-connector-java" % "5.1.36",
"com.amazonaws" % "aws-java-sdk-s3" % AwsSdkversion,
"org.scalaj" %% "scalaj-http" % "2.3.0",
"org.scalatest" %% "scalatest" % ScalaTestVersion % "test",
"org.mockito" % "mockito-all" % MockitoVersion % "test",
"org.flywaydb" % "flyway-core" % "4.0",
"org.elasticsearch.client" % "elasticsearch-rest-high-level-client" % "6.0.1",
"com.sksamuel.elastic4s" %% "elastic4s-core" % Elastic4sVersion,
"com.sksamuel.elastic4s" %% "elastic4s-http" % Elastic4sVersion,
"com.sksamuel.elastic4s" %% "elastic4s-aws" % Elastic4sVersion,
"org.elasticsearch" % "elasticsearch" % ElasticsearchVersion,
"org.elasticsearch" % "elasticsearch" % ElasticsearchVersion % "test",
"org.apache.lucene" % "lucene-test-framework" % "6.4.1" % "test",
"org.jsoup" % "jsoup" % "1.7.3",
"org.imgscalr" % "imgscalr-lib" % "4.2",
"com.netaporter" %% "scala-uri" % "0.4.16",
"io.sentry" % "sentry-log4j2" % "1.7.3",
// These two are not strictly needed, for most cases, but offers better handling of loading images with encoding issues
"com.twelvemonkeys.imageio" % "imageio-core" % "3.3.2",
"com.twelvemonkeys.imageio" % "imageio-jpeg" % "3.3.2",
"com.cloudinary" % "cloudinary-http44" % "1.2.1"
)
).enablePlugins(DockerPlugin).enablePlugins(GitVersioning).enablePlugins(JettyPlugin)
assemblyJarName in assembly := "image-api.jar"
mainClass in assembly := Some("no.ndla.imageapi.JettyLauncher")
assemblyMergeStrategy in assembly := {
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 PathList("META-INF", "org", "apache", "logging", "log4j", "core", "config", "plugins", "Log4j2Plugins.dat") => MergeStrategy.first
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
// 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!
testOptions in Test += 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
dockerfile in docker := {
val artifact = (assemblyOutputPath in assembly).value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("openjdk:8-jre-alpine")
add(artifact, artifactTargetPath)
entryPoint("java", "-Dorg.scalatra.environment=production", "-jar", artifactTargetPath)
}
}
val gitHeadCommitSha = settingKey[String]("current git commit SHA")
gitHeadCommitSha in ThisBuild := Process("git log --pretty=format:%h -n 1").lines.head
imageNames in docker := Seq(
ImageName(
namespace = Some(organization.value),
repository = name.value,
tag = Some(System.getProperty("docker.tag", "SNAPSHOT")))
)
parallelExecution in Test := false
resolvers ++= Seq(
scala.util.Properties.envOrNone("GDL_RELEASES").map(repo => "GDL Release Sonatype Nexus Repository Manager" at repo),
scala.util.Properties.envOrNone("NDLA_RELEASES").map(repo => "NDLA Release Sonatype Nexus Repository Manager" at repo)
).flatten