-
Notifications
You must be signed in to change notification settings - Fork 98
/
build.sbt
278 lines (245 loc) · 9.43 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
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
import ReleaseTransformations._
import scala.language.postfixOps
import scala.sys.process._
// ---------
// Setting / Task Definitions
// ---------
lazy val vegaLiteVersion = settingKey[String]("The release version of vega-lite to build off")
lazy val updateVegaDeps = taskKey[Unit]("Download and replace the vega-lite json schema and examples with the latest versions from their github repo")
updateVegaDeps := {
val specResources = (resourceDirectory in Compile in vegaLiteSpec).value
val coreResources = (resourceDirectory in Compile in vegas).value
val coreTestResources = (resourceDirectory in Test in vegas).value
val vegaDir = target.value / ("vega-lite-" + vegaLiteVersion.value)
IO.unzipURL(new URL("https://github.com/vega/vega-lite/archive/v" + vegaLiteVersion.value + ".zip"), target.value)
IO.copyDirectory(vegaDir / "examples" / "specs", coreTestResources / "example-specs", true)
IO.copyFile(vegaDir / "vega-lite-schema.json", specResources / "vega-lite-schema.json")
// Write WebJar.csv to resources, based on ivy-deps
val deps = (externalDependencyClasspath in vegas in Compile).value
val webJars = deps
.map { artifact =>
val m = artifact.get(Keys.moduleID.key).get
(m.organization, m.name, m.revision)
}
.filter(_._1 == "org.webjars.bower")
.map { case(_,n,v) => s"$n,$v" }
.mkString("\n")
IO.write(coreResources / "webjars.csv", webJars)
}
addCommandAlias("look", "vegas/test:runMain vegas.util.Look")
lazy val mkVegaModel = taskKey[Unit]("Compiles and copies the vega-lite model and codec to the Vegas project")
mkVegaModel := {
val src = (scalaBinaryVersion.value match {
case "2.11" => file("spec/target/scala-2.11/Spec.scala")
case "2.12" => file("spec/target/scala-2.12/Spec.scala")
})
val dest = file("core/src/main/scala/vegas/spec/Spec.scala")
IO.write(dest, """
|// This file was automatically generated by the `sbt mkVegaModel` command.
|// Do NOT edit manually.
|
|package vegas.spec
|
|""".stripMargin
)
IO.append(dest, IO.readBytes(src))
}
mkVegaModel := mkVegaModel
.dependsOn(compile in vegaLiteSpec in Compile)
.value
lazy val lastReleaseVersion = taskKey[String]("Gets (using git tag) the version number of the last release")
lastReleaseVersion := {
("git tag" !!).split("\n").head.tail
}
lazy val mkNotebooks = inputKey[Unit]("Generates /notebook examples based on example plots in the test fixtures")
mkNotebooks := (Def.inputTaskDyn {
val ver = version.value
val baseDir = file("core/src/test/scala/vegas/fixtures")
val files = (baseDir / "BasicPlots.scala") :: (baseDir / "VegasPlots.scala") :: Nil
val dest = file("notebooks")
val args = (ver :: files) :+ dest
Def.taskDyn {
(runMain in vegas in Test).toTask(" vegas.util.GenerateNotebooks " + args.mkString(" "))
}
}).evaluated
// -------
// Build Config
// -------
lazy val circeVersion = "0.7.0"
lazy val commonSettings = Seq(
description := "The missing matplotlib for Scala and Spark",
organization := "org.vegas-viz",
crossScalaVersions := Seq("2.11.8", "2.12.10"),
scalaVersion := "2.12.10",
vegaLiteVersion := "1.2.0",
scalacOptions ++= Seq("-target:jvm-1.7", "-Ywarn-unused-import"),
homepage := Some(url("http://vegas-viz.org")),
licenses := Seq("MIT License" -> url("http://www.opensource.org/licenses/MIT")),
// parallelExecution in Test := false,
addCompilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.full),
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
sonatypeProfileName := "org.vegas-viz",
pomExtra := (
<scm>
<url>[email protected]:vegas-viz/Vegas.git</url>
<connection>scm:git:[email protected]:vegas-viz/Vegas.git</connection>
</scm>
<developers>
<developer>
<id>aishfenton</id>
<name>Aish Fenton</name>
</developer>
<developer>
<id>datamusing</id>
<name>Sudeep Das</name>
</developer>
<developer>
<id>dbtsai</id>
<name>DB Tsai</name>
</developer>
<developer>
<id>rogermenezes</id>
<name>Roger Menezes</name>
</developer>
</developers>
),
testOptions in Test += Tests.Argument("-oDF"),
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
releaseStepInputTask(mkNotebooks),
commitReleaseVersion,
tagRelease,
// ReleaseStep(action = Command.process("publishSigned", _)),
ReleaseStep(action = st => st.copy(remainingCommands = Exec("publishSigned", None) +: st.remainingCommands)),
setNextVersion,
commitNextVersion,
// ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
ReleaseStep(action = st => st.copy(remainingCommands = Exec("sonatypeReleaseAll", None) +: st.remainingCommands)),
pushChanges
)
)
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val macros = project.
settings(moduleName := "vegas-macros").
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.typelevel" %% "macro-compat" % "1.1.1",
"com.github.julien-truffaut" %% "monocle-core" % (scalaBinaryVersion.value match {
case "2.11" => "1.1.0"
case "2.12" => "1.3.2"
})
)
)
// This project exists just to generate the Vega-Lite Json model + codecs
lazy val vegaLiteSpec = project.in(file("spec")).
settings(commonSettings: _*).
settings(noPublishSettings: _*).
settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"com.github.aishfenton" %% "argus" % "0.2.7",
"org.scalactic" %% "scalactic" % "3.0.5" % "test",
"org.scalatest" %% "scalatest" % "3.0.5" % "test"
)
)
// settings(sourceGenerators in Compile <+= (sourceManaged in Compile) map genCode)
// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
}
lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
lazy val vegas = project.in(file("core")).
settings(moduleName := "vegas").
dependsOn(macros).
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"com.github.julien-truffaut" %% "monocle-macro" % (scalaBinaryVersion.value match {
case "2.11" => "1.1.0"
case "2.12" => "1.3.2"
}),
"com.github.julien-truffaut" %% "monocle-core" % (scalaBinaryVersion.value match {
case "2.11" => "1.1.0"
case "2.12" => "1.3.2"
}),
"org.scalafx" %% "scalafx" % "12.0.2-R18",
"org.scala-lang.modules" %% "scala-xml" % "1.0.6",
// JS deps. Also used to generate "webjars.csv" file for CDN loading.
"org.webjars.bower" % "vega-lite" % vegaLiteVersion.value,
// Test deps
"com.github.aishfenton" %% "argus" % "0.2.7" % "test",
"org.scalactic" %% "scalactic" % "3.0.5" % "test",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"org.seleniumhq.selenium" % "selenium-java" % "3.13.0" % "test"
) ++ javaFXModules.map( m =>
"org.openjfx" % s"javafx-$m" % "11" classifier osName
)
)
// https://stackoverflow.com/questions/48653876/aggregate-different-modules-based-on-scala-binary-version
lazy val spark = project.
settings(moduleName := "vegas-spark").
dependsOn(vegas % "compile->compile; test->test").
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % "[2.0,)" % "provided"
)
).
// remove spark dep and skip compile if version is 2.12
settings(
libraryDependencies := (if (scalaBinaryVersion.value == "2.12") Seq.empty
else libraryDependencies.value),
skip in compile := scalaBinaryVersion.value == "2.12",
skip in publish := scalaBinaryVersion.value == "2.12"
)
lazy val flink = project.
settings(moduleName := "vegas-flink").
dependsOn(vegas).
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"org.apache.flink" %% "flink-scala" % "[1.1.1,)" % "provided",
"org.apache.flink" %% "flink-clients" % "[1.1.1,)" % "provided"
)
).
settings(
libraryDependencies := (if (scalaBinaryVersion.value == "2.12") Seq.empty
else libraryDependencies.value),
skip in compile := scalaBinaryVersion.value == "2.12",
skip in publish := scalaBinaryVersion.value == "2.12"
)
lazy val root = (project in file(".")).
aggregate(vegas, spark, flink, macros).
settings(commonSettings: _*).
settings(noPublishSettings: _*)
// Clears screen between refreshes in continuous mode
maxErrors := 5
triggeredMessage := Watched.clearWhenTriggered