-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
202 lines (157 loc) · 6.84 KB
/
build.sc
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
import $ivy.`com.goyeau::mill-scalafix::0.2.10`
import com.goyeau.mill.scalafix.ScalafixModule
import mill._, scalalib._, scalafmt._
import mill.scalalib.publish._
val Scala12 = "2.12.16"
val Scala13 = "2.13.8"
val CatsCore = ivy"org.typelevel::cats-core:2.7.0"
val CatsParse = ivy"org.typelevel::cats-parse:0.3.7"
val CatsEffect = ivy"org.typelevel::cats-effect:3.3.14"
val SuperTagged = ivy"org.rudogma::supertagged:2.0-RC2"
val SourceCode = ivy"com.lihaoyi::sourcecode:0.3.0"
val ScalaCheck = ivy"org.scalacheck::scalacheck:1.16.0"
val ScalaTest = ivy"org.scalatest::scalatest:3.2.13"
val WordSpec = Set(ScalaTest, ivy"org.scalatest::scalatest-wordspec:3.2.13")
val PropSpec = Set(
ScalaTest,
ivy"org.scalatest::scalatest-propspec:3.2.13",
ivy"org.scalatestplus::scalacheck-1-16:3.2.12.0"
)
val MUnit = ivy"org.scalameta::munit:0.7.29"
trait StyleModule extends ScalafmtModule with ScalafixModule {
override def scalafixIvyDeps = super.scalafixIvyDeps() ++ Agg(
ivy"com.github.liancheng::organize-imports:0.6.0",
ivy"org.typelevel::typelevel-scalafix:0.1.5"
)
def commonScalacOptions = Seq(
"-encoding",
"UTF-8",
"-deprecation",
"-unchecked",
"-feature",
"-Ywarn-unused",
"-Ywarn-dead-code",
"-Ywarn-value-discard",
"-Xfatal-warnings",
"-language:higherKinds"
)
override def forkEnv: T[Map[String, String]] = super.forkEnv().updated("SCALACTIC_FILL_FILE_PATHNAMES", "yes")
def versionSpecificOptions(version: String) = version match {
case Scala12 =>
Seq(
"-Ywarn-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-unused-import",
"-Ypartial-unification"
)
case _ => Seq()
}
def crossScalaVersion: String
override def scalacOptions =
super.scalacOptions() ++ commonScalacOptions ++ versionSpecificOptions(crossScalaVersion)
override def scalaDocOptions = super.scalaDocOptions() ++ Seq("-no-link-warnings")
override def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(
ivy"com.olegpy::better-monadic-for:0.3.1",
ivy"org.typelevel:::kind-projector:0.13.2"
)
}
trait CommonModule
extends CrossScalaModule
with StyleModule
with PublishModule {
override def artifactName: T[String] = T { s"commons-${super.artifactName()}" }
def publishVersion: T[String] = "0.3.0"
override def pomSettings: T[PomSettings] = PomSettings(
description = "Scala Commons - common utilities for Scala projects",
organization = "com.github.morgen-peschke",
url = "https://github.com/morgen-peschke/scala-commons",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("morgen-peschke", "scala-commons"),
developers = Seq(
Developer(
"morgen-peschke",
"Morgen Peschke",
"https://github.com/morgen-peschke"
)
)
)
protected def outerCrossScalaVersion: String = crossScalaVersion
}
trait UsingScalaTestModule extends TestModule.ScalaTest with StyleModule
trait UsingMunitTestModule extends TestModule.Munit with StyleModule
object core extends Cross[CoreModule](Scala12, Scala13)
class CoreModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps = Agg(CatsCore, CatsParse, SuperTagged)
object test extends Tests with UsingScalaTestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(
WordSpec ++ PropSpec + ivy"org.python:jython-slim:2.7.2"
)
override def crossScalaVersion: String = outerCrossScalaVersion
}
}
object collections extends Cross[CollectionsModule](Scala12, Scala13)
class CollectionsModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(CatsCore)
object test extends Tests with UsingScalaTestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(scalacheck(crossScalaVersion))
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(WordSpec ++ PropSpec)
}
}
object scalacheck extends Cross[ScalaCheckModule](Scala12, Scala13)
class ScalaCheckModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(ScalaCheck)
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(
core(crossScalaVersion),
collections(crossScalaVersion)
)
object test extends Tests with UsingScalaTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(PropSpec)
}
}
object decline extends Cross[DeclineModule](Scala12, Scala13)
class DeclineModule(val crossScalaVersion: String) extends CommonModule {
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(core(crossScalaVersion))
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(
CatsCore,
ivy"com.monovore::decline:2.3.0"
)
}
object shims extends Cross[ShimsModule](Scala12, Scala13)
class ShimsModule(val crossScalaVersion: String) extends CommonModule {
override def moduleDeps: Seq[PublishModule] = super.moduleDeps ++ Seq(core(crossScalaVersion))
object test extends Tests with UsingScalaTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(WordSpec)
}
}
object testing extends Cross[TestingModule](Scala12, Scala13)
class TestingModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Seq(SourceCode, SuperTagged, CatsEffect, CatsCore)
object test extends Tests with UsingMunitTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(MUnit)
}
}
object munit extends Cross[MunitModule](Scala12, Scala13)
class MunitModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Seq(MUnit)
override def moduleDeps: Seq[PublishModule] = super.moduleDeps :+ testing(crossScalaVersion)
object test extends Tests with UsingMunitTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(MUnit)
}
}
object scalatest extends Cross[ScalaTestModule](Scala12, Scala13)
class ScalaTestModule(val crossScalaVersion: String) extends CommonModule {
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Seq(ScalaTest)
override def moduleDeps: Seq[PublishModule] = super.moduleDeps :+ testing(crossScalaVersion)
object test extends Tests with UsingScalaTestModule {
override def crossScalaVersion: String = outerCrossScalaVersion
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg.from(WordSpec)
}
}