-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.sbt
201 lines (180 loc) · 5.47 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
import sbtcrossproject.{CrossProject, CrossType, Platform}
/// variables
val groupId = "eu.timepit"
val projectName = "fs2-cron"
val rootPkg = s"$groupId.${projectName.replace("-", "")}"
val Scala_2_12 = "2.12.20"
val Scala_2_13 = "2.13.15"
val Scala_3 = "3.6.2"
val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map(
"calev" -> List(JVMPlatform, JSPlatform),
"core" -> List(JVMPlatform, JSPlatform),
"cron4s" -> List(JVMPlatform),
"cron-utils" -> List(JVMPlatform)
)
/// global settings
ThisBuild / organization := groupId
ThisBuild / tlBaseVersion := "0.9"
ThisBuild / startYear := Some(2018)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers := List(
tlGitHubDev("fthomas", "Frank S. Thomas")
)
ThisBuild / scalaVersion := Scala_2_13
ThisBuild / crossScalaVersions := List(Scala_2_12, Scala_2_13, Scala_3)
ThisBuild / tlCiReleaseBranches := Seq("master")
ThisBuild / tlSonatypeUseLegacyHost := true
ThisBuild / githubWorkflowBuild ++= Seq(
WorkflowStep.Sbt(
commands = List("readme/mdoc"),
name = Some("Check README"),
cond = Some(s"matrix.scala != '3' && matrix.project == 'rootJVM'")
),
WorkflowStep.Sbt(
commands = List("coverage", "test", "coverageReport"),
name = Some("Generate coverage report"),
cond = Some(s"matrix.scala != '3'")
),
WorkflowStep.Use(
ref = UseRef.Public("codecov", "codecov-action", "v4"),
name = Some("Codecov"),
env = Map("CODECOV_TOKEN" -> "${{ secrets.CODECOV_TOKEN }}")
)
)
ThisBuild / mergifyPrRules := {
val authorCondition = MergifyCondition.Or(
List(
MergifyCondition.Custom("author=scala-steward"),
MergifyCondition.Custom("author=scala-steward[bot]")
)
)
Seq(
MergifyPrRule(
"label scala-steward's PRs",
List(authorCondition),
List(MergifyAction.Label(List("dependency-update")))
),
MergifyPrRule(
"merge scala-steward's PRs",
List(authorCondition) ++ mergifySuccessConditions.value,
List(MergifyAction.Merge(Some("merge")))
)
)
}
/// projects
lazy val root = tlCrossRootProject
.aggregate(calev, core, cron4s, cronUtils, readme)
lazy val core = myCrossProject("core")
.settings(
libraryDependencies ++= Seq(
"co.fs2" %%% "fs2-core" % "3.11.0",
"org.typelevel" %%% "munit-cats-effect" % "2.0.0" % Test
)
)
.jsSettings(
tlVersionIntroduced := Map(
"2.12" -> "0.8.3",
"2.13" -> "0.8.3",
"3" -> "0.8.3"
)
)
lazy val calev = myCrossProject("calev")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += "com.github.eikek" %%% "calev-core" % "0.7.3",
initialCommands += s"""
import $rootPkg.calev._
import com.github.eikek.calev._
"""
)
.jsSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.6.0" % Test,
tlVersionIntroduced := Map(
"2.12" -> "0.8.3",
"2.13" -> "0.8.3",
"3" -> "0.8.3"
)
)
lazy val cron4s = myCrossProject("cron4s")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += "com.github.alonsodomin.cron4s" %% "cron4s-core" % "0.7.0",
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.12."))
List(scalaOrganization.value % "scala-reflect" % scalaVersion.value)
else
List()
},
initialCommands += s"""
import $rootPkg.cron4s._
import _root_.cron4s.Cron
import _root_.cron4s.expr.CronExpr
"""
)
lazy val cronUtils = myCrossProject("cron-utils")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += "com.cronutils" % "cron-utils" % "9.2.1",
initialCommands += s"""
import $rootPkg.cronutils._
import com.cronutils.model.CronType
import com.cronutils.model.definition.CronDefinitionBuilder
import com.cronutils.model.time.ExecutionTime
import com.cronutils.parser.CronParser
""",
tlVersionIntroduced := Map(
"2.12" -> "0.8.2",
"2.13" -> "0.8.2",
"3" -> "0.8.2"
)
)
lazy val readme = project
.in(file("modules/readme"))
.enablePlugins(MdocPlugin, NoPublishPlugin)
.dependsOn(calev.jvm, cron4s.jvm)
.settings(commonSettings)
.settings(
crossScalaVersions := List(Scala_2_12, Scala_2_13),
scalacOptions -= "-Xfatal-warnings",
mdocIn := baseDirectory.value / "README.md",
mdocOut := (LocalRootProject / baseDirectory).value / "README.md",
mdocVariables := Map(
"VERSION" -> tlLatestVersion.value.get
)
)
/// settings
def myCrossProject(name: String): CrossProject =
CrossProject(name, file(name))(moduleCrossPlatformMatrix(name): _*)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file(s"modules/$name"))
.settings(moduleName := s"$projectName-$name")
.settings(commonSettings)
lazy val commonSettings = Def.settings(
compileSettings,
metadataSettings
)
lazy val compileSettings = Def.settings(
scalaVersion := Scala_2_13,
crossScalaVersions := List(Scala_2_12, Scala_2_13, Scala_3),
initialCommands := s"""
import $rootPkg._
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import fs2.Stream
"""
)
lazy val metadataSettings = Def.settings(
headerLicense := Some(HeaderLicense.ALv2("2018-2023", s"$projectName contributors"))
)
/// commands
def addCommandsAlias(name: String, cmds: Seq[String]) =
addCommandAlias(name, cmds.mkString(";", ";", ""))
addCommandsAlias(
"fmt",
Seq(
"headerCreateAll",
"scalafmtAll",
"scalafmtSbt"
)
)