-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sbt
135 lines (116 loc) · 3.98 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
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
ThisBuild / organization := "ai.lum"
ThisBuild / scalaVersion := "2.12.10"
ThisBuild / fork := true
/* You can print computed classpath by `show compile:fullClassPath`.
* From that list you can check jar name (that is not so obvious with play dependencies etc).
*/
lazy val documentationSettings = Seq(
// see https://www.scala-sbt.org/1.x/docs/Howto-Scaladoc.html#Enable+automatic+linking+to+the+external+Scaladoc+of+managed+dependencies
autoAPIMappings := true,
)
lazy val commonSettings = Seq(
// show test duration
Test / testOptions += Tests.Argument("-oD"),
excludeDependencies += "commons-logging" % "commons-logging",
)
lazy val core = project
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings)
.settings(
buildInfoPackage := "ai.lum.odinson",
buildInfoOptions += BuildInfoOption.ToJson,
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
"builtAt" -> {
val date = new java.util.Date
val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
formatter.format(date)
},
"gitCurrentBranch" -> { git.gitCurrentBranch.value },
"gitHeadCommit" -> { git.gitHeadCommit.value.getOrElse("") },
"gitHeadCommitDate" -> { git.gitHeadCommitDate.value.getOrElse("") },
"gitUncommittedChanges" -> { git.gitUncommittedChanges.value }
)
)
lazy val extra = project
.aggregate(core)
.dependsOn(core)
.settings(commonSettings)
.enablePlugins(JavaAppPackaging, DockerPlugin)
.settings(generalDockerSettings)
.settings(
Docker / packageName := "odinson-extras",
//mainClass in Compile := Some("ai.lum.odinson.extra.IndexDocuments"),
//dockerRepository := Some("index.docker.io"),
//dockerChmodType := DockerChmodType.UserGroupWriteExecute
Universal / javaOptions ++= Seq(
"-J-Xmx6G"
)
)
// Docker settings
val gitDockerTag = settingKey[String]("Git commit-based tag for docker")
ThisBuild / gitDockerTag := {
val shortHash: String = git.gitHeadCommit.value.get.take(7)
val uncommittedChanges: Boolean = (git.gitUncommittedChanges).value
s"""${shortHash}${if (uncommittedChanges) "-DIRTY" else ""}"""
}
lazy val generalDockerSettings = {
Seq(
ThisBuild / parallelExecution := false,
// see https://www.scala-sbt.org/sbt-native-packager/formats/docker.html
Docker / daemonUserUid := None,
Docker / daemonUser := "root",
dockerUsername := Some("lumai"),
dockerAliases ++= Seq(
dockerAlias.value.withTag(Option("latest")),
dockerAlias.value.withTag(Option(gitDockerTag.value))
),
Docker / maintainer := "Gus Hahn-Powell <ghp@lum.ai>",
dockerBaseImage := "adoptopenjdk/openjdk11",
Universal / javaOptions ++= Seq(
"-Dodinson.dataDir=/app/data/odinson"
)
)
}
// Release steps
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
// Publishing settings
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / publishMavenStyle := true
Test / publishArtifact := false
ThisBuild / licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / homepage := Some(url("https://github.com/lum-ai/odinson"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/lum-ai/odinson"),
"scm:git@github.com:lum-ai/odinson.git"
)
)
ThisBuild / developers := List(
Developer(
id = "marcovzla",
name = "Marco Antonio Valenzuela Escárcega",
email = "marco@lum.ai",
url = url("https://lum.ai")
)
)
// tasks
addCommandAlias("dockerize", ";clean;compile;test;docker:publishLocal")
addCommandAlias("dockerizeAndPublish", ";clean;compile;test;docker:publish")