-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sbt
147 lines (117 loc) · 4.14 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
import java.io.PrintWriter
import scala.io.Source
name := "mockito-5.12"
organization := "org.scalatestplus"
version := "3.2.19.0"
homepage := Some(url("https://github.com/scalatest/scalatestplus-mockito"))
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
)
developers := List(
Developer(
"bvenners",
"Bill Venners",
url("https://github.com/bvenners")
),
Developer(
"cheeseng",
"Chua Chee Seng",
url("https://github.com/cheeseng")
)
)
scalaVersion := "2.13.13"
crossScalaVersions := List("2.11.12", "2.12.19", "2.13.13", "3.3.3")
libraryDependencies ++= Seq(
"org.mockito" % "mockito-core" % "5.12.0",
"org.scalatest" %% "scalatest-core" % "3.2.19",
"org.scalatest" %% "scalatest-funsuite" % "3.2.19" % "test"
)
import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
import scala.xml.transform.{RewriteRule, RuleTransformer}
// skip dependency elements with a scope
pomPostProcess := { (node: XmlNode) =>
new RuleTransformer(new RewriteRule {
override def transform(node: XmlNode): XmlNodeSeq = node match {
case e: Elem
if e.label == "dependency"
&& e.child.exists(child => child.label == "scope") =>
def txt(label: String): String =
"\"" + e.child
.filter(_.label == label)
.flatMap(_.text)
.mkString + "\""
Comment(
s""" scoped dependency ${txt("groupId")} % ${txt("artifactId")} % ${txt(
"version"
)} % ${txt("scope")} has been omitted """
)
case _ => node
}
}).transform(node).head
}
enablePlugins(SbtOsgi)
osgiSettings
OsgiKeys.exportPackage := Seq("org.scalatestplus.mockito.*")
OsgiKeys.importPackage := Seq(
"org.scalatest.*",
"org.scalactic.*",
"scala.*;version=\"$<range;[==,=+);$<replace;" + scalaBinaryVersion.value + ";-;.>>\"",
"*;resolution:=optional"
)
OsgiKeys.additionalHeaders := Map(
"Bundle-Name" -> "ScalaTestPlusMockito",
"Bundle-Description" -> "ScalaTest+Mockito is an open-source integration library between ScalaTest and Mockito for Scala projects.",
"Bundle-DocURL" -> "http://www.scalatest.org/",
"Bundle-Vendor" -> "Artima, Inc."
)
publishTo := {
val nexus = "https://oss.sonatype.org/"
Some("publish-releases" at nexus + "service/local/staging/deploy/maven2")
}
publishMavenStyle := true
Test / publishArtifact := false
pomIncludeRepository := { _ =>
false
}
pomExtra := (
<scm>
<url>https://github.com/scalatest/scalatestplus-mockito</url>
<connection>scm:git:[email protected]:scalatest/scalatestplus-mockito.git</connection>
<developerConnection>
scm:git:[email protected]:scalatest/scalatestplus-mockito.git
</developerConnection>
</scm>
)
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
// Temporary disable publishing of doc in dotty, can't get it to build.
Compile / packageDoc / publishArtifact := !scalaBinaryVersion.value.startsWith("3")
def docTask(docDir: File, resDir: File, projectName: String): File = {
val docLibDir = docDir / "lib"
val htmlSrcDir = resDir / "html"
val cssFile = docLibDir / "template.css"
val addlCssFile = htmlSrcDir / "addl.css"
val css = Source.fromFile(cssFile).mkString
val addlCss = Source.fromFile(addlCssFile).mkString
if (!css.contains("pre.stHighlighted")) {
val writer = new PrintWriter(cssFile)
try {
writer.println(css)
writer.println(addlCss)
}
finally { writer.close }
}
if (projectName.contains("scalatest")) {
(htmlSrcDir * "*.gif").get.foreach { gif =>
IO.copyFile(gif, docLibDir / gif.name)
}
}
docDir
}
Compile / doc := docTask((Compile / doc).value,
(Compile / sourceDirectory).value,
name.value)
Compile / doc / scalacOptions := Seq("-doc-title", s"ScalaTest + Mockito ${version.value}",
"-sourcepath", baseDirectory.value.getAbsolutePath(),
"-doc-source-url", s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-mockito/${version.value}€{FILE_PATH}.scala")