-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sbt
172 lines (159 loc) · 5.29 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
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
import sbt.ForkOptions
import sbt.Tests._
val catsV = "2.12.0"
val scalaJavaLocalesV = "1.5.4"
val scalacheckV = "1.18.1"
val munitV = "1.0.1"
val disciplineMunitV = "2.0.0"
ThisBuild / tlVersionIntroduced := Map(
"3" -> "1.1.4"
)
// Utility
lazy val wildcardImport: SettingKey[Char] =
settingKey[Char]("Character to use for wildcard imports.")
ThisBuild / wildcardImport := {
if (tlIsScala3.value) {
'*'
} else {
'_'
}
}
/** Helper function to build the correct initial commands to full import the given packages. Order
* is important here.
*/
def fullImports(packages: List[String], wildcard: Char): String =
packages.map(value => s"import ${value}.${wildcard}").mkString("\n")
// Projects
lazy val root = tlCrossRootProject.aggregate(core, testing, tests, bench)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(
name := "case-insensitive",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsV
),
console / initialCommands := {
fullImports(List("cats", "cats.syntax.all", "org.typelevel.ci"), wildcardImport.value)
},
// For some reason consoleQuick delegates to console, which doesn't make
// sense to me since the only difference is that console compiles the
// local module, but consoleQuick only has the dependencies. That is,
// you'd use consoleQuick if the local build isn't building and you just
// wanted to fiddle with a dependency on the classpath. But the only place
// to put local module imports has to be console, but since consoleQuick
// delegates to that, that will break consoleQuick by default. So...
consoleQuick / initialCommands := {
fullImports(List("cats", "cats.syntax.all"), wildcardImport.value)
}
)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.5.0").toMap
)
lazy val testing = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("testing"))
.settings(
name := "case-insensitive-testing",
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalacheckV
),
console / initialCommands := {
fullImports(
List(
"cats",
"cats.syntax.all",
"org.typelevel.ci",
"org.typelevel.ci.testing",
"org.typelevel.ci.testing.arbitraries",
"org.scalacheck"),
wildcardImport.value
)
},
consoleQuick / initialCommands := {
fullImports(List("cats", "cats.syntax.all", "org.scalacheck"), wildcardImport.value)
}
)
.platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-locales" % scalaJavaLocalesV
)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.5.0").toMap
)
.dependsOn(core)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("tests"))
.enablePlugins(NoPublishPlugin)
.settings(
name := "case-insensitive-tests",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-laws" % catsV,
"org.scalameta" %%% "munit" % munitV,
"org.typelevel" %%% "discipline-munit" % disciplineMunitV
).map(_ % Test),
Test / console / initialCommands := {
fullImports(
List(
"cats",
"cats.syntax.all",
"org.typelevel.ci",
"org.typelevel.ci.testing",
"org.typelevel.ci.testing.arbitraries",
"org.scalacheck"),
wildcardImport.value
)
},
Test / consoleQuick / initialCommands := {
fullImports(List("cats", "cats.syntax.all", "org.scalacheck"), wildcardImport.value)
}
)
.jvmSettings(
Test / testGrouping := {
val (turkish, english) = (Test / definedTests).value.partition(_.name.contains("Turkey"))
def group(language: String, tests: Seq[TestDefinition]) =
new Group(
language,
tests,
SubProcess(ForkOptions().withRunJVMOptions(Vector(s"-Duser.language=$language"))))
List(
group("en", english),
group("tr", turkish)
)
}
)
.dependsOn(testing)
lazy val bench = project
.in(file("bench"))
.enablePlugins(NoPublishPlugin)
.enablePlugins(JmhPlugin)
.settings(
name := "case-insensitive-bench",
console / initialCommands := {
fullImports(List("cats", "cats.syntax.all", "org.typelevel.ci"), wildcardImport.value)
},
consoleQuick / initialCommands := ""
)
.dependsOn(core.jvm)
lazy val docs = project
.in(file("site"))
.dependsOn(core.jvm, testing.jvm)
.enablePlugins(TypelevelSitePlugin)
val Scala213 = "2.13.15"
// General Settings
inThisBuild(
List(
tlBaseVersion := "1.5",
scalaVersion := Scala213,
crossScalaVersions := Seq("2.12.20", Scala213, "3.3.4"),
developers := List(
tlGitHubDev("rossabaker", "Ross A. Baker")
),
homepage := Some(url("https://typelevel.org/case-insensitive")),
tlSiteApiUrl := Some(url(
"https://www.javadoc.io/doc/org.typelevel/case-insensitive_2.13/latest/org/typelevel/ci/index.html")),
startYear := Some(2020),
// Remove cursed tags
tlMimaPreviousVersions ~= { old => old -- Set("1.4.1") }
))