-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
147 lines (138 loc) · 7.32 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
lazy val scalaLib = ExclusionRule("org.scala-lang", "scala-library")
lazy val slf4jApi = ExclusionRule("org.slf4j", "slf4j-api")
lazy val dependencies = Seq(
"org.scalatest" %% "scalatest" % "3.0.4" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.5" % "test",
"com.lihaoyi" %% "fastparse" % "1.0.0",
"com.github.pathikrit" %% "better-files" % "3.0.0" excludeAll(
scalaLib
),
"com.typesafe.scala-logging" %% "scala-logging" % "3.5.0" excludeAll(
ExclusionRule("org.scala-lang", "scala-reflect"),
scalaLib,
slf4jApi // use the one provided by logback
),
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.github.scopt" %% "scopt" % "3.5.0",
"com.sksamuel.scrimage" %% "scrimage-core" % "2.1.8" excludeAll(
scalaLib,
slf4jApi // use the one provided by logback
),
"org.xerial" % "sqlite-jdbc" % "3.21.0",
"com.typesafe" % "config" % "1.3.2",
"org.bouncycastle" % "bcpg-jdk15on" % "1.58",
"eu.medsea.mimeutil" % "mime-util" % "2.1.3" excludeAll(
ExclusionRule("log4j", "log4j"),
ExclusionRule("org.slf4j", "slf4j-log4j12")
),
"com.github.eikek" %% "yamusca-core" % "0.4.0"
)
lazy val writeTestInfo = Def.task {
val code = s"""package chee
| import better.files._
| object TestInfo {
| val baseDir = file"${baseDirectory.value}"
| val targetDir = file"${(target in Test).value}"
| val resourceDir = file"${(resourceDirectory in Test).value}"
| val gnupgDir = resourceDir / "gnupg"
| val images: List[File] =
| ${IO.listFiles((resourceDirectory in Test).value / "images").map( f => "resourceDir / \"images\" / \"" + f.getName + "\"").toList}
| val sampleDb = resourceDir / "sample.db"
| /** Repo dir is /home/eike/workspace */
| val sampleRepoDb = resourceDir / "sampleRepo.db"
|}
""".stripMargin
val file = (sourceManaged in Test).value / "chee" / "TestInfo.scala"
IO.write(file, code)
Seq(file)
}
lazy val ItTest = config("itTest") extend Test
def itFilter(name: String): Boolean = (name endsWith "Test") && (name.startsWith("chee.cli") || name.startsWith("chee.it"))
def unitFilter(name: String): Boolean = ((name endsWith "Test") || (name endsWith "Spec")) && !itFilter(name)
lazy val testSettings = Defaults.itSettings ++ Seq(
fork in Test := true,
fork in ItTest := true,
javaOptions in Test ++= Seq(
"-Duser.timezone=Europe/Berlin",
s"-Dchee.workingdir=${(target in Test).value}/test/.chee-dir",
s"-Dchee.configdir=${(target in Test).value}/test/.chee-dir",
s"-Duser.dir=${(target in Test).value}/test"
),
testOptions in Test := Seq(Tests.Filter(unitFilter)),
testOptions in ItTest := Seq(Tests.Filter(itFilter)),
sourceGenerators in Test += writeTestInfo.taskValue,
scalacOptions in Test := (scalacOptions in (Compile, console)).value,
scalacOptions in ItTest := (scalacOptions in (Compile, console)).value
)
lazy val bootstrapVersion = "3.3.7"
lazy val galleryVersion = "2.21.3"
lazy val jqueryVersion = "3.1.1"
lazy val fontAwesomeVersion = "4.6.3"
lazy val markedVersion = "0.3.6"
lazy val themes = List("cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "lumen",
"paper", "readable", "sandstone", "simplex", "slate", "spacelab", "superhero", "united", "yeti")
lazy val buildSettings = Seq(
libraryDependencies := dependencies,
resourceLibs in Compile ++= Seq(
// js
Lib.js(jqueryVersion, "http://code.jquery.com/jquery-<version>.min.js"),
Lib.js(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/js/jquery.blueimp-gallery.min.js"),
Lib.js(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/js/blueimp-gallery.min.js"),
Lib.js(markedVersion, "https://github.com/chjj/marked/raw/v<version>/marked.min.js"),
//css
Lib.css(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/css/font-awesome.min.css"),
Lib.css(bootstrapVersion, "http://netdna.bootstrapcdn.com/bootstrap/<version>/css/bootstrap.min.css").in("bootstrap"),
Lib.css(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/css/blueimp-gallery.min.css"),
// fonts
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/FontAwesome.otf"),
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/fontawesome-webfont.eot"),
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/fontawesome-webfont.svg"),
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/fontawesome-webfont.ttf"),
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/fontawesome-webfont.woff"),
Lib.font(fontAwesomeVersion, "https://maxcdn.bootstrapcdn.com/font-awesome/<version>/fonts/fontawesome-webfont.woff2"),
// img
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/error.png"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/error.svg"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/play-pause.png"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/play-pause.svg"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/loading.gif"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/video-play.png"),
Lib.img(galleryVersion, "https://github.com/blueimp/Gallery/raw/v<version>/img/video-play.svg")
) ++ themes.map(theme => Lib.css(bootstrapVersion, s"https://maxcdn.bootstrapcdn.com/bootswatch/<version>/${theme}/bootstrap.min.css").in(theme)),
resourceGenerators in Compile += (listDocResources in CheeDoc).taskValue,
resourceGenerators in Compile += (fetchResources in Compile).taskValue,
sourceGenerators in Compile += (genDocInfo in CheeDoc).taskValue,
sourceGenerators in Compile += (resourceInfo in Compile).taskValue.map(f => Seq(f)),
packageOptions in (Compile, packageBin) += Package.ManifestAttributes(
"Class-Path" -> Attributed.data((fullClasspath in Runtime).value).
withFilter(_.isFile).
map(_.getName).
mkString(" ")
)
)
addCommandAlias("run-all-tests", ";genDocResources;test;itTest:test")
addCommandAlias("make-chee", ";genDocResources;gen-chee")
addCommandAlias("make-zip", ";run-all-tests;gen-zip;gen-chee")
lazy val chee = (project in file(".")).
configs(ItTest, CheeDoc, script).
settings(inConfig(ItTest)(Defaults.testTasks): _*).
settings(
name := "chee",
homepage := Some(url("https://github.com/eikek/chee")),
scalaVersion := "2.12.4",
scalacOptions ++= Seq(
"-encoding", "UTF-8",
"-Xfatal-warnings", // fail when there are warnings
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-unused-import"
),
scalacOptions in (Compile, console) ~= (_.filterNot(Set("-Xfatal-warnings", "-Ywarn-unused-import").contains))
).
settings(testSettings: _*).
settings(buildSettings: _*)