This repository was archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
141 lines (128 loc) · 5.19 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
lazy val gpdvizVersion = getVersion
val scalaV = "2.12.4"
val akkaHttpV = "10.0.10"
val akkaHttpCorsV = "0.2.2"
val cfgV = "0.0.7"
val scalatestV = "3.0.3"
val esriV = "1.2.1"
val pusherV = "1.0.0"
val autowireV = "0.2.6"
val upickleV = "0.4.4"
val pprintV = "0.5.2"
val swaggerAkkaV = "0.11.0"
val postgresV = "42.1.4"
val slickV = "3.2.1"
val slickPgV = "0.15.4"
val scalaLoggingV = "3.7.2"
val logbackV = "1.2.3"
val scalaJsDomV = "0.9.3"
val bindingV = "10.0.2"
val macrosParadiseV = "2.1.0"
val momentScalaJsV = "0.9.0"
def commonSettings = Seq(
name := "gpdviz",
version := gpdvizVersion,
scalaVersion := scalaV,
scalaJSUseMainModuleInitializer := true,
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "autowire" % autowireV,
"com.lihaoyi" %%% "upickle" % upickleV,
"com.lihaoyi" %%% "pprint" % pprintV
),
scalacOptions ++= Seq("-deprecation", "-feature", "-encoding", "utf8"
//, "-Ywarn-dead-code"
//, "-unchecked",
//, "-Xlint"
//, "-Ywarn-unused-import"
)
)
lazy val root = project.in(file("."))
.aggregate(gpdvizJS, gpdvizJVM)
.settings(
publish := {},
publishLocal := {}
)
//lazy val gpdviz = crossProject(JVMPlatform, JSPlatform) // Use this with ScalaJs 1.x
lazy val gpdviz = crossProject
.in(file("."))
.settings(commonSettings: _*)
.jvmSettings(
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided",
"com.typesafe.akka" %% "akka-http" % akkaHttpV,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpV,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV,
"ch.megard" %% "akka-http-cors" % akkaHttpCorsV,
"org.scalatest" %% "scalatest" % scalatestV % "test",
"com.github.carueda" %% "cfg" % cfgV % "provided",
"com.esri.geometry" % "esri-geometry-api" % esriV,
"com.pusher" % "pusher-http-java" % pusherV
,"org.postgresql" % "postgresql" % postgresV
,"com.typesafe.slick" %% "slick" % slickV
,"com.typesafe.slick" %% "slick-hikaricp" % slickV
,"com.github.tminglei" %% "slick-pg" % slickPgV
,"com.github.tminglei" %% "slick-pg_spray-json" % slickPgV
,"com.github.swagger-akka-http" %% "swagger-akka-http" % swaggerAkkaV
,"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV
,"ch.qos.logback" % "logback-classic" % logbackV
),
addCompilerPlugin(
("org.scalameta" % "paradise" % "3.0.0-M10").cross(CrossVersion.full)
),
mainClass in assembly := Some("gpdviz.Gpdviz"),
assemblyJarName in assembly := s"gpdviz-$gpdvizVersion.jar"
)
.jsSettings(
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % scalaJsDomV,
"com.thoughtworks.binding" %%% "dom" % bindingV,
"ru.pavkin" %%% "scala-js-momentjs" % momentScalaJsV
),
addCompilerPlugin("org.scalamacros" % "paradise" % macrosParadiseV cross CrossVersion.full),
mainClass in Compile := Some("gpdviz.webapp.Frontend"),
jsDependencies ++= Seq(
"org.webjars" % "momentjs" % "2.18.1" / "moment.js" minified "moment.min.js",
"org.webjars" % "lodash" % "4.17.4" / "lodash.js" minified "lodash.min.js",
"org.webjars" % "jquery" % "3.2.1" / "jquery.js" minified "jquery.min.js",
"org.webjars" % "leaflet" % "1.0.0" / "leaflet.js",
"org.webjars" % "esri-leaflet" % "2.0.7" / "esri-leaflet.js" dependsOn "leaflet.js",
"org.webjars" % "highstock" % "6.0.2" / "6.0.2/highstock.js"
)
)
lazy val gpdvizJS = gpdviz.js
lazy val gpdvizJVM = gpdviz.jvm.settings(
(resources in Compile) += (fastOptJS in (gpdvizJS, Compile)).value.data
)
// Puts some js resources under jvm's classpath so they can be resolved.
// Execute 'package' to trigger this.
resourceGenerators in Compile += Def.task {
val parentDir = (fastOptJS in Compile in gpdvizJS).value.data.getParentFile
def copy(name: String): File = {
val sourceFile = parentDir / name
require (sourceFile.exists())
val destFile = (classDirectory in Compile in gpdvizJVM).value / sourceFile.name
println(s"::: copying $sourceFile --> $destFile")
IO.copyFile(sourceFile, destFile)
destFile
}
Seq(
copy("gpdviz-fastopt.js.map"),
copy("gpdviz-jsdeps.js")
)
}.taskValue
def getVersion: String = {
val version = {
val refFile = file("jvm/src/main/resources/reference.conf")
val versionRe = """gpdviz\.version\s*=\s*(.+)""".r
IO.read(refFile).trim match {
case versionRe(v) ⇒ v
case _ ⇒ sys.error(s"could not parse gpdviz.version from $refFile")
}
}
println(s"gpdviz.version = $version")
val indexFile = file("jvm/src/main/resources/web/index.html")
val contents = IO.readLines(indexFile).mkString("\n")
val updated = contents.replaceAll("<!--v-->[^<]*<!--v-->", s"<!--v-->$version<!--v-->")
IO.write(indexFile, updated)
version
}