-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
211 lines (177 loc) · 8 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
import java.nio.file.Files
import sbt._
import sbt.Keys._
import sbtdynver.impl.NoProcessLogger
import sys.process._
import scala.util.Try
name := "pomisos"
scalaVersion := "2.12.6"
resolvers += "jitpack" at "https://jitpack.io"
resolvers += Resolver.bintrayRepo("jerady", "maven")
val gremlinVersion = "3.2.3."
val sfxVersion = "0.5"
val macwireVersion = "2.3.0"
val akkaVersion = "2.4.17"
val logbackVersion = "1.2.2"
val smileVersion = "1.3.1"
libraryDependencies ++= Seq(
"org.scalafx" %% "scalafx" % "8.0.192-R14",
"org.scalafx" %% "scalafxml-core-sfx8" % sfxVersion,
"org.scalafx" %% "scalafxml-macwire-sfx8" % sfxVersion,
"de.jensd" % "fontawesomefx-fontawesome" % "4.7.0-9.1.2",
"com.jfoenix" % "jfoenix" % "8.0.4",
"org.controlsfx" % "controlsfx" % "8.40.12",
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
"com.typesafe.akka" %% "akka-http" % "10.0.3",
"de.heikoseeberger" %% "akka-http-upickle" % "1.12.0",
"com.lihaoyi" %% "upickle" % "0.4.4",
"com.michaelpollmeier" %% "gremlin-scala" % (gremlinVersion + "4"),
"com.michaelpollmeier" % "orientdb-gremlin" % (gremlinVersion + "0"),
"com.softwaremill.macwire" %% "macros" % macwireVersion % "provided",
"com.softwaremill.macwire" %% "util" % macwireVersion,
"com.softwaremill.macwire" %% "macrosakka" % macwireVersion,
"com.github.haifengl" %% "smile-scala" % smileVersion,
"com.softwaremill.quicklens" %% "quicklens" % "1.4.8",
"com.chuusai" %% "shapeless" % "2.3.2",
"org.typelevel" %% "cats-core" % "1.4.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.5.0",
"ch.qos.logback" % "logback-core" % logbackVersion,
"ch.qos.logback" % "logback-classic" % logbackVersion,
"org.slf4j" % "jul-to-slf4j" % "1.7.25",
"com.typesafe.akka" %% "akka-testkit" % "2.4.17" % "test",
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.mockito" % "mockito-all" % "1.9.0" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.4" % "test",
"com.fortysevendeg" %% "scalacheck-toolbox-datetime" % "0.2.1" % "test"
)
mainClass in assembly := Some("net.mikolak.pomisos.main.App")
assemblyJarName in assembly := "pomisos.jar"
assemblyMergeStrategy in assembly := {
case x if x.endsWith("groovy-release-info.properties") => MergeStrategy.first
case x if x.contains("xmlpull") => MergeStrategy.first
case x => (assemblyMergeStrategy in assembly).value(x)
}
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
val makeIcons = taskKey[Seq[File]]("make them icons")
resourceGenerators in Compile += makeIcons.taskValue
fork in run := true //so that OrientDB runs correctly
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest,
"-u",
sys.env.getOrElse("CIRCLE_TEST_REPORTS", target.value) + "/test-reports")
enablePlugins(JavaAppPackaging, JDKPackagerPlugin)
//sets data dir as a fallback in case something fails in-app
bashScriptExtraDefines +=
s"""BASE_DATA_PATH=$${XDG_DATA_HOME:-$$HOME/.local/share}
|DATA_PATH=$$BASE_DATA_PATH/${name.value}
|mkdir -p $$DATA_PATH
|cd $$DATA_PATH
""".stripMargin
maintainer := "Mikołaj Koziarkiewicz"
packageSummary := "Pomisos Pomodoro App"
packageDescription := "A pomodoro app with several cool features"
maintainer in JDKPackager := "mikolak.net"
version in JDKPackager := {
val baseDynVersion = (version in Compile).value.replaceAll("\\-", ".")
if (!baseDynVersion.matches("^[0-9].*")) {
s"0.$baseDynVersion"
} else {
baseDynVersion
}
}
lazy val iconGlob = sys.props("os.name") match {
case os if os.contains("Mac OS") => "icon.icns"
case os if os.contains("Win") => "icon.ico"
case _ => "icon.png"
}
jdkAppIcon := (sourceDirectory.value ** iconGlob).getPaths.headOption.map(file)
jdkPackagerType := "all"
jdkPackagerJVMArgs := Seq("-Xmx512m")
jdkPackagerProperties := Map("app.name" -> name.value,
"app.version" -> version.value,
"info.license" -> "Apache License, Version 2.0",
"info.category" -> "Office")
jdkPackagerAppArgs := Seq(maintainer.value, packageSummary.value, packageDescription.value)
//rewrite ant task to actually use the info keys
antBuildDefn in JDKPackager := {
val origTask = (antBuildDefn in JDKPackager).value
val InfoLabel = "info"
val KeyRegex = s"$InfoLabel\\.(.+)".r
import scala.xml._
import scala.xml.transform._
val infoRewrite = new RewriteRule {
override def transform(n: Node) = n match {
case e: Elem if e.prefix == "fx" && e.label == InfoLabel =>
val attribMap = jdkPackagerProperties.value.collect {
case (KeyRegex(infoKey), value) =>
(infoKey, value)
}
attribMap.foldRight(e) {
case ((key, value), infoElem) => infoElem % Attribute("", key, value, Null)
}
case other => other
}
}
new RuleTransformer(infoRewrite)(origTask)
}
makeIcons := {
val inputFileName = "icon.svg"
val inputName = inputFileName.split('.').head
val inputFile = new File(inputFileName)
val outputBasePath = (resourceDirectory in Compile).value
val log = streams.value.log
case class ImgSpec(suffix: String, size: Int, format: String) {
val outputFile = outputBasePath / s"$inputName$suffix.$format"
}
val commandChecks = List("inkscape --version", "convert", "png2icns")
def generateCmd(spec: ImgSpec)(outFile: File = spec.outputFile): List[List[String]] =
if (spec.format == "png") {
List(
List(
"inkscape",
s"--file=${baseDirectory.value / inputFileName}",
s"--export-${spec.format}=${outFile.absolutePath}",
s"-w${spec.size}",
s"-h${spec.size}",
"--export-area-page"
))
} else {
val tempExtension = "png"
val tempFile = Files.createTempFile("", s".$tempExtension").toFile
Files.delete(tempFile.toPath)
val otherCommand = if (spec.format == "icns") {
List("png2icns", spec.outputFile.absolutePath, tempFile.absolutePath)
} else {
List("convert", tempFile.absolutePath, spec.outputFile.absolutePath)
}
generateCmd(spec.copy(format = tempExtension))(tempFile) :+
otherCommand
}
val outputFiles = List(ImgSpec("_small", 24, "png"),
ImgSpec("", 64, "png"),
ImgSpec("_large", 128, "png"),
ImgSpec("", 64, "ico"),
ImgSpec("", 128, "icns"))
val filesToRefresh = outputFiles.filter { spec =>
val out = spec.outputFile
!out.exists() || (out.lastModified < inputFile.lastModified)
}
def doRefresh() = {
import sys.process._
import language.postfixOps
for (spec <- filesToRefresh) yield {
val out = spec.outputFile
generateCmd(spec)().foreach(cmd => log.info(Process(cmd) !!))
out
}
}
if (commandChecks.forall(cmd => Try(cmd.!(NoProcessLogger)).isSuccess)) {
doRefresh()
} else {
if (filesToRefresh.nonEmpty) {
log.warn(
s"Icons need to be updated, but either of ${commandChecks.mkString(", ")} is missing. Install to allow regeneration.")
}
Seq.empty[File]
}
}