-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
144 lines (130 loc) · 4.85 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
import sbtcrossproject.CrossPlugin.autoImport.CrossType
import sbtcrossproject.CrossProject
val Version = new {
val CatsEffect = "3.5.7"
val CatsMtl = "1.5.0"
val Circe = "0.14.10"
val Fs2 = "3.11.0"
val Http4s = "1.0.0-M43"
val Java = "17"
val Log4Cats = "2.7.0"
val Munit = "1.0.3"
val MunitCatsEffect = "2.0.0"
val Scala3 = "3.3.4"
val Slf4j = "1.7.36"
val Slf4j2 = "2.0.16"
}
def module(identifier: Option[String], jvmOnly: Boolean, crossType: CrossType = CrossType.Pure): CrossProject = {
val platforms = List(JVMPlatform) ++ (if (jvmOnly) Nil else List(JSPlatform))
CrossProject(identifier.getOrElse("root"), file(identifier.fold(".")("modules/" + _)))(platforms: _*)
.crossType(crossType)
.withoutSuffixFor(JVMPlatform)
.build()
.settings(
Compile / scalacOptions ++= "-source:future" :: "-rewrite" :: "-new-syntax" :: "-Wunused:all" :: Nil,
name := "flog" + identifier.fold("")("-" + _)
)
}
def jpmsOverwriteModulePath(modulePaths: Seq[File])(options: Seq[String]): Seq[String] = {
val modPathString = modulePaths.map(_.getAbsolutePath).mkString(java.io.File.pathSeparator)
val option = "--module-path"
val index = options.indexWhere(_ == option)
if (index == -1) options ++ List(option, modPathString)
else options.patch(index + 1, List(modPathString), 1)
}
inThisBuild(
Def.settings(
developers := List(Developer("taig", "Niklas Klein", "[email protected]", url("https://taig.io/"))),
dynverVTagPrefix := false,
homepage := Some(url("https://github.com/taig/flog/")),
licenses := List("MIT" -> url("https://raw.githubusercontent.com/taig/flog/main/LICENSE")),
organization := "io.taig",
scalaVersion := Version.Scala3,
versionScheme := Some("early-semver")
)
)
lazy val root = module(identifier = None, jvmOnly = true)
.enablePlugins(BlowoutYamlPlugin)
.settings(noPublishSettings)
.settings(
blowoutGenerators ++= {
val github = file(".github")
val workflows = github / "workflows"
BlowoutYamlGenerator.lzy(workflows / "main.yml", GithubActionsGenerator.main(Version.Java)) ::
BlowoutYamlGenerator.lzy(workflows / "pull-request.yml", GithubActionsGenerator.pullRequest(Version.Java)) ::
BlowoutYamlGenerator.lzy(workflows / "tag.yml", GithubActionsGenerator.tag(Version.Java)) ::
Nil
}
)
.aggregate(core, slf4j, slf4j2, http4s, http4sClient, http4sServer, sample)
lazy val core = module(Some("core"), jvmOnly = false)
.settings(
libraryDependencies ++=
"co.fs2" %%% "fs2-core" % Version.Fs2 ::
"io.circe" %%% "circe-core" % Version.Circe ::
"org.typelevel" %%% "cats-effect" % Version.CatsEffect ::
"org.typelevel" %%% "cats-mtl" % Version.CatsMtl ::
"org.scalameta" %%% "munit" % Version.Munit % "test" ::
"org.typelevel" %%% "munit-cats-effect" % Version.MunitCatsEffect % "test" ::
Nil
)
lazy val slf4j = module(Some("slf4j"), jvmOnly = true)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoObject := "Build",
buildInfoKeys := Seq("slf4jVersion" -> Version.Slf4j),
buildInfoPackage := s"${organization.value}.flog.slf4j",
libraryDependencies ++=
"org.slf4j" % "slf4j-api" % Version.Slf4j ::
Nil
)
.dependsOn(core)
lazy val slf4j2 = module(Some("slf4j-2"), jvmOnly = true, CrossType.Full)
.enablePlugins(BuildInfoPlugin)
.settings(
Compile / doc / sources := Seq.empty,
compileOrder := CompileOrder.JavaThenScala,
javacOptions := jpmsOverwriteModulePath((Compile / dependencyClasspath).value.map(_.data))(javacOptions.value),
javaOptions := jpmsOverwriteModulePath((Compile / dependencyClasspath).value.map(_.data))(javaOptions.value),
libraryDependencies ++=
"org.slf4j" % "slf4j-api" % Version.Slf4j2 ::
Nil
)
.dependsOn(core)
lazy val log4cats = module(Some("log4cats"), jvmOnly = false)
.settings(
libraryDependencies ++=
"org.typelevel" %%% "log4cats-core" % Version.Log4Cats ::
Nil
)
.dependsOn(core)
lazy val http4s = module(Some("http4s"), jvmOnly = true)
.settings(
libraryDependencies ++=
"org.http4s" %% "http4s-core" % Version.Http4s ::
Nil
)
.dependsOn(core)
lazy val http4sClient = module(Some("http4s-client"), jvmOnly = true)
.settings(
libraryDependencies ++=
"org.http4s" %% "http4s-client" % Version.Http4s ::
Nil
)
.dependsOn(http4s)
lazy val http4sServer = module(Some("http4s-server"), jvmOnly = true)
.settings(
libraryDependencies ++=
"org.http4s" %% "http4s-server" % Version.Http4s ::
Nil
)
.dependsOn(http4s)
lazy val sample = module(Some("sample"), jvmOnly = true)
.settings(noPublishSettings)
.settings(
libraryDependencies ++=
"org.http4s" %% "http4s-dsl" % Version.Http4s ::
"org.http4s" %% "http4s-ember-server" % Version.Http4s ::
Nil
)
.dependsOn(http4sServer, log4cats)