forked from RomanIakovlev/timeshape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
125 lines (114 loc) · 4.34 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
import scala.sys.process._
import _root_.io.circe.parser._
val dataVersion = "2020a"
val softwareVersion = "10"
val `commons-compress` = Seq(
"org.apache.commons" % "commons-compress" % "1.20",
"com.github.luben" % "zstd-jni" % "1.4.4-9"
)
val commonSettings = Seq(
organization := "net.iakovlev",
sonatypeProfileName := "net.iakovlev",
version := s"$dataVersion.$softwareVersion",
crossPaths := false,
autoScalaLibrary := false,
publishMavenStyle := true
)
lazy val timeshape = (project in file("."))
.settings(commonSettings)
.aggregate(core, builder, testApp, `geojson-proto`, benchmarks)
.settings(skip in publish := true)
lazy val builderArgument = settingKey[String](
"Argument to pass to builder, either local path to source data file or version to download")
lazy val releaseTask = taskKey[Unit](
"Publishes an artifact and optionally makes a release if version is not a snapshot")
lazy val getLatestRelease: String = {
val src = scala.io.Source.fromURL("https://api.github.com/repos/evansiroky/timezone-boundary-builder/releases/latest")
val json = src.mkString
json
}
lazy val core = (project in file("core"))
.settings(commonSettings)
.settings(
builderArgument := dataVersion,
libraryDependencies ++= Seq(
"com.esri.geometry" % "esri-geometry-api" % "2.2.3",
"junit" % "junit" % "4.12" % Test,
"com.novocode" % "junit-interface" % "0.11" % Test
exclude ("junit", "junit-dep"),
"org.slf4j" % "slf4j-api" % "1.7.30",
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3",
"net.iakovlev" % "geojson-proto" % "1.1.0"
) ++ `commons-compress`,
name := "timeshape",
publishTo := sonatypePublishTo.value,
packageOptions in (Compile, packageBin) += Package.ManifestAttributes("Automatic-Module-Name" -> "net.iakovlev.timeshape"),
resourceGenerators in Compile += Def.taskDyn {
val log = streams.value.log
val outputPath = (resourceManaged in Compile).value
val outputFile = outputPath / "data.tar.zstd"
outputPath.mkdirs()
if (!outputFile.exists()) {
log.info("Timeshape resource doesn't exist in this host, creating it now.")
val jsonString = getLatestRelease
val latest: String = parse(jsonString)
.flatMap(_.hcursor.downField("name").as[String])
.getOrElse("Unknown")
if (latest != builderArgument.value) {
log.warn(s"Latest timezone data release is : $latest, while this build uses ${builderArgument.value}")
}
log.info("Downloading timezone data with version: " + builderArgument.value)
val command =
s"java -jar ${(builder / assembly).value} ${builderArgument.value} ${outputFile.getAbsolutePath}"
log.info(s"running $command")
command.!
} else {
log.info("Timeshape resource exists, skipping creation")
}
Def.task(Seq(outputFile))
}.taskValue,
releaseTask := {
publish.value
val buildState = state.value
if (!isSnapshot.value) Command.process("sonatypeRelease", buildState)
}
)
lazy val `geojson-proto` = (project in file("geojson-proto"))
.settings(commonSettings)
.settings(
publishTo := sonatypePublishTo.value,
version := "1.1.1-SNAPSHOT",
PB.targets in Compile := Seq(
PB.gens.java("3.10.0") -> (sourceManaged in Compile).value
),
javacOptions ++= Seq("-Xdoclint:none"),
releaseTask := {
publish.value
val buildState = state.value
if (!isSnapshot.value) Command.process("sonatypeRelease", buildState)
}
)
lazy val builder = (project in file("builder"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"de.grundid.opendatalab" % "geojson-jackson" % "1.8.1"
) ++ `commons-compress`,
name := "timeshape-builder",
skip in publish := true
)
.dependsOn(`geojson-proto`)
lazy val testApp = (project in file("test-app"))
.settings(commonSettings)
.settings(
mainClass in assembly := Some("net.iakovlev.timeshape.testapp.Main"),
skip in publish := true,
libraryDependencies ++= Seq("org.openjdk.jol" % "jol-core" % "0.9",
"ch.qos.logback" % "logback-classic" % "1.2.3")
)
.dependsOn(core)
lazy val benchmarks = (project in file("benchmarks"))
.settings(commonSettings)
.settings(skip in publish := true)
.dependsOn(core)
.enablePlugins(JmhPlugin)