-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
215 lines (184 loc) · 6.59 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
import java.io.{BufferedReader, InputStreamReader}
enablePlugins(JavaAppPackaging)
lazy val xmlCalabashVersion = "2.99.12"
lazy val jafplVersion = "0.3.84"
lazy val saxonVersion = "10.6"
lazy val useSaxonEE = Option(System.getProperty("saxonEdition")).getOrElse("HE") == "EE"
name := "XML Calabash"
organization := "com.xmlcalabash"
homepage := Some(url("https://xmlcalabash.com/"))
version := xmlCalabashVersion
scalaVersion := "2.13.8"
maintainer := "[email protected]" // for packaging
Global / excludeLintKeys += homepage
Global / excludeLintKeys += organization
buildInfoUsePackageAsPath := true
buildInfoKeys ++= Seq[BuildInfoKey](
"jafplVersion" -> jafplVersion,
BuildInfoKey.action("buildTime") {
System.currentTimeMillis
},
// Hat tip to: https://stackoverflow.com/questions/24191469/how-to-add-commit-hash-to-play-templates
"gitHash" -> new java.lang.Object() {
override def toString: String = {
try {
val extracted = new InputStreamReader(
java.lang.Runtime.getRuntime.exec("git rev-parse HEAD").getInputStream
)
new BufferedReader(extracted).readLine
} catch {
case _: Exception => "FAILED"
}
}}.toString()
)
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion),
buildInfoPackage := "com.xmlcalabash.sbt"
)
lazy val debugSbtTask = taskKey[Unit]("Task for debugging things I don't understand about sbt")
debugSbtTask := {
println(unmanagedClasspath.toString())
println(managedClasspath)
}
lazy val failTask = taskKey[Unit]("Force the build to fail")
failTask := {
throw new sbt.MessageOnlyException("No build for you.")
}
// Redefine publish so that it will fail if the repo is dirty
publish := Def.taskDyn {
val default = publish.taskValue
val shortstat = {
try {
val extracted = new InputStreamReader(
java.lang.Runtime.getRuntime.exec("git diff --shortstat").getInputStream
)
var diff = ""
val reader = new BufferedReader(extracted)
var line = reader.readLine
while (line != null) {
diff = line
line = reader.readLine
}
reader.close()
diff
} catch {
case _: Exception => "FAILED"
}
}
val status = {
try {
val extracted = new InputStreamReader(
java.lang.Runtime.getRuntime.exec("git status --porcelain").getInputStream
)
var newFile = ""
val reader = new BufferedReader(extracted)
var line = reader.readLine
while (line != null) {
if (line.startsWith("??")) {
newFile = line
}
line = reader.readLine
}
reader.close()
newFile
} catch {
case _: Exception => "FAILED"
}
}
val message = if (shortstat != "") {
if (status != "") {
Some("Repository has changed and untracked files.")
} else {
Some("Repository has changed files.")
}
} else if (status != "") {
Some("Repository has untracked files.")
} else {
None
}
if (message.isDefined) {
println(message.get)
}
if (message.isDefined) {
Def.taskDyn {
failTask
}
} else {
Def.task(default.value)
}
}.value
resolvers += "Artima Maven Repository" at "https://repo.artima.com/releases"
resolvers += "Restlet" at "https://maven.restlet.talend.com"
resolvers += "Saxonica" at "https://dev.saxonica.com/maven"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.36"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.11"
libraryDependencies += "org.apache.commons" % "commons-compress" % "1.21"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.3"
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.1.0"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
//libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "2.1.1"
libraryDependencies += "com.ibm.icu" % "icu4j" % "71.1"
libraryDependencies += "org.apache.httpcomponents" % "httpcore" % "4.4.15"
libraryDependencies += "org.apache.httpcomponents" % "httpmime" % "4.5.13"
libraryDependencies +=
"org.apache.httpcomponents" % "httpclient" % "4.5.13" excludeAll(
ExclusionRule(organization = "commons-logging")
)
libraryDependencies += "org.restlet.jee" % "org.restlet" % "2.2.2"
libraryDependencies += "org.xmlresolver" % "xmlresolver" % "4.5.0"
libraryDependencies += "nu.validator" % "htmlparser" % "1.4.16"
libraryDependencies += "com.atlassian.commonmark" % "commonmark" % "0.17.0"
libraryDependencies += "com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % "2.13.3"
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.3"
libraryDependencies +=
"org.relaxng" % "jing" % "20220510" excludeAll(
ExclusionRule(organization = "com.sun.xml.bind.jaxb"),
ExclusionRule(organization = "isorelax"),
ExclusionRule(organization = "relaxngDatatype"),
ExclusionRule(organization = "net.sf.saxon")
)
libraryDependencies += "com.jafpl" % "jafpl_2.13" % jafplVersion
libraryDependencies +=
"com.nwalsh" % "sinclude" % "4.1.0" excludeAll(
ExclusionRule(organization="com.saxonica"),
ExclusionRule(organization="net.sf.saxon"))
libraryDependencies ++= (
if (useSaxonEE) {
Seq("com.saxonica" % "Saxon-EE" % saxonVersion)
} else {
Seq("net.sf.saxon" % "Saxon-HE" % saxonVersion)
}
)
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.3" % "test"
dependencyOverrides += "xml-apis" % "xml-apis" % "1.3.04"
// The Urify tests have to mock the OS. If execution of
// The Windows and NonWindows variants overlaps, bad happens.
Test / parallelExecution := false
// ============================================================
//Compile / unmanagedClasspath += file(s"${baseDirectory.value}/lib")
//Runtime / unmanagedClasspath += file(s"${baseDirectory.value}/lib")
//Test / unmanagedClasspath += file(s"${baseDirectory.value}/lib")
Runtime / unmanagedClasspath ++= (
if (useSaxonEE) {
Seq(file(s"${baseDirectory.value}/eelib"))
} else {
Seq()
}
)
Test / unmanagedClasspath ++= (
if (useSaxonEE) {
Seq(file(s"${baseDirectory.value}/eelib"))
} else {
Seq()
}
)
// Yes, this is an odd place for local use, but it's where the website
// needs them. I should figure out how to parameterize the location...
//target in Compile in doc := baseDirectory.value / "build/pages/apidocs"
//scalacOptions in (Compile, doc) ++= Seq(
// "-doc-root-content", baseDirectory.value+"/docs/apidocs/root.md"
//)
scalacOptions := Seq("-unchecked", "-deprecation")
javacOptions := Seq("-Xlint:unchecked", "-Xlint:deprecation")