-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
227 lines (204 loc) · 6.76 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
216
217
218
219
220
221
222
223
224
225
226
227
import org.typelevel.idna4s.build._
ThisBuild / tlBaseVersion := "0.1"
val UnicodeVersion: String = "15.0.0"
val Scala212 = "2.12.17"
val Scala213 = "2.13.10"
val Scala3 = "3.2.2"
def DefaultScalaVersion: String = Scala213
val catsCollectionsV = "0.9.6"
val catsV = "2.8.0"
val disciplineMunitV = "2.0.0-M3"
val icu4jV = "73.1"
val literallyV = "1.1.0"
val munitV = "1.0.0-M6"
val scalacheckV = "1.17.0"
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / scalaVersion := Scala213
ThisBuild / developers += tlGitHubDev("isomarcte", "David Strawn")
ThisBuild / licenses := List(License.MIT)
ThisBuild / startYear := Some(2022)
// SBT Commands
// Calls prePR, but also the additional commands needed to run on the meta
// project defined in the project/ directory.
//
// Also adds scalafixAll, as that is not in prePR.
addCommandAlias(
"prePRAll",
s";+scalafixAll;+prePR;reload plugins;clean;scalafixAll;headerCreateAll;test")
addCommandAlias(
"prePRLight",
s";prePR;reload plugins;scalafixAll;headerCreateAll;"
)
// Utility
lazy val wildcardImport: SettingKey[Char] =
settingKey[Char]("Character to use for wildcard imports.")
ThisBuild / wildcardImport := {
if (tlIsScala3.value) {
'*'
} else {
'_'
}
}
// Scalafix
// Use the scalafix config which is valid for all versions of Scala if
// scalaVersion is different than the default one. Otherwise, use the full
// scalafix config, which includes Scala version specific rules.
ThisBuild / scalafixConfig := {
if ((LocalRootProject / scalaVersion).value != DefaultScalaVersion) {
Some(file(".scalafix-base.conf"))
} else scalafixConfig.value
}
ThisBuild / scalafixScalaBinaryVersion := {
if ((LocalRootProject / scalaVersion).value != DefaultScalaVersion) {
// This is the default according to Scalafix, but the key
// `scalafixScalaBinaryVersion` isn't actually set in the Global scope, so
// we can't use `scalafixScalaBinaryVersion.value` here. I believe they
// are defaulting the the plugin code, rather than in the sbt scope,
// e.g. `scalafixScalaBinaryVersion.value.?.getOrElse("2.12")`
"2.12"
} else {
(LocalRootProject / scalaBinaryVersion).value
}
}
ThisBuild / ScalafixConfig / skip := tlIsScala3.value
// SBT Typelevel Github Actions
ThisBuild / githubWorkflowGeneratedCI += WorkflowJob(
id = "codegen",
name = "Codegen Test/Lint",
steps = List(
WorkflowStep.Checkout,
WorkflowStep.Sbt(commands =
List("reload plugins", "headerCheckAll", "scalafixAll --check", "test"))),
scalas = List(Scala212)
)
ThisBuild / githubWorkflowEnv ++= Map(
"JAVA_TOOL_OPTIONS" -> "-XX:+UseG1GC -XX:MaxHeapFreeRatio=20 -Xmx4G -XX:MinHeapFreeRatio=10 -XX:+UseStringDeduplication"
)
// Projects
lazy val projectName: String = "idna4s"
lazy val root = tlCrossRootProject
.aggregate(
core,
scalacheck,
tests,
benchmarks
)
.settings(name := projectName)
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("core"))
.settings(
name := s"${projectName}-core",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-collections-core" % catsCollectionsV,
"org.typelevel" %%% "cats-core" % catsV
),
libraryDependencies ++= {
// Needed for macros
if (tlIsScala3.value) {
Nil
} else {
List(
"org.typelevel" %%% "literally" % literallyV,
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
)
}
},
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit-scalacheck" % munitV,
"org.typelevel" %%% "discipline-munit" % disciplineMunitV
).map(_ % Test),
console / initialCommands := {
List(
"cats.",
"cats.syntax.all.",
"org.typelevel.idna4s.core.",
"org.typelevel.idna4s.core.uts46.",
"org.typelevel.idna4s.core.bootstring.",
"org.typelevel.idna4s.core.syntax.all."
).map(value => s"import ${value}${wildcardImport.value}").mkString("\n")
},
consoleQuick / initialCommands := "",
Compile / sourceGenerators ++= List(
(Compile / sourceManaged)
.map(
CodeGen.generate(_, UnicodeVersion)
)
.taskValue
)
)
lazy val scalacheck = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("scalacheck"))
.settings(
name := s"${projectName}-scalacheck",
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalacheckV
),
console / initialCommands := {
List(
"cats.",
"cats.syntax.all.",
"org.scalacheck.",
"org.typelevel.idna4s.core.",
"org.typelevel.idna4s.core.bootstring.",
"org.typelevel.idna4s.core.syntax.all.",
"org.typelevel.idna4s.core.uts46.",
"org.typelevel.idna4s.scalacheck.all."
).map(value => s"import ${value}${wildcardImport.value}").mkString("\n")
},
consoleQuick / initialCommands := ""
)
.dependsOn(core)
lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("tests"))
.settings(
name := s"${projectName}-tests",
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-munit" % disciplineMunitV,
"org.typelevel" %%% "cats-laws" % catsV
),
Test / console / initialCommands := {
List(
"cats.",
"cats.syntax.all.",
"org.scalacheck.",
"org.typelevel.idna4s.core.",
"org.typelevel.idna4s.core.bootstring.",
"org.typelevel.idna4s.core.syntax.all.",
"org.typelevel.idna4s.core.uts46.",
"org.typelevel.idna4s.scalacheck.all."
).map(value => s"import ${value}${wildcardImport.value}").mkString("\n")
},
consoleQuick / initialCommands := ""
)
.jvmSettings(
libraryDependencies ++= Seq(
"com.ibm.icu" % "icu4j" % icu4jV
).map(_ % Test)
)
.dependsOn(core % Test, scalacheck % Test)
.enablePlugins(NoPublishPlugin)
lazy val benchmarks = project
.in(file("benchmarks"))
.settings(
libraryDependencies ++= List(
"com.ibm.icu" % "icu4j" % icu4jV
),
console / initialCommands := {
List(
"cats.",
"cats.syntax.all.",
"org.scalacheck.",
"org.typelevel.idna4s.core.",
"org.typelevel.idna4s.core.bootstring.",
"org.typelevel.idna4s.core.syntax.all.",
"org.typelevel.idna4s.core.uts46.",
"org.typelevel.idna4s.scalacheck.all."
).map(value => s"import ${value}${wildcardImport.value}").mkString("\n")
},
consoleQuick / initialCommands := ""
)
.dependsOn(core.jvm, scalacheck.jvm)
.enablePlugins(NoPublishPlugin, JmhPlugin)