-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.sbt
215 lines (194 loc) · 7.46 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
import Dependencies._
import ReleaseTransformations._
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
/* TODO: Attempts to do this with the existing `TaskKey` have failed, but that
* would be better than doing it using the string. This approach also won't
* work if you were to dynamically modify the cross-build settings. The key is
* autoimported and named `mimaReportBinaryIssues`. */
lazy val binaryCompatStep = releaseStepCommandAndRemaining("+mimaReportBinaryIssues")
// Workarounds for Dotty being incomplete
lazy val testIfRelevantStep = releaseStepCommandAndRemaining("+testIfRelevant")
lazy val publishIfRelevantStep = releaseStepCommandAndRemaining("+publishSignedIfRelevant")
/* This is the standard release process plus a binary compat check after tests */
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
testIfRelevantStep,
binaryCompatStep,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishIfRelevantStep,
setNextVersion,
commitNextVersion,
pushChanges
)
val prevVersions = settingKey[Set[String]]("The previous versions for the current project")
val prevArtifacts = Def.derive {
mimaPreviousArtifacts := prevVersions.value.map(organization.value %%% artifact.value.name % _)
}
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("testIfRelevant", "mimaReportBinaryIssues")))
ThisBuild / githubWorkflowJavaVersions := Seq("8", "11", "17").map(JavaSpec.temurin)
ThisBuild / githubWorkflowScalaVersions := crossScalaVersions.value
ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty
def jsOpts = new Def.SettingList(Seq(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) },
))
lazy val root: Project = (project in file ("."))
.enablePlugins(BasicSettings)
.settings(Publish.settings: _*)
.settings(Release.settings: _*)
.aggregate(coreJVM, coreJS, testingJVM, testingJS)
.settings (
name := "Log4s Root",
publish := {},
publishLocal := {},
publishArtifact := false,
exportJars := false,
Compile / skip := true,
Test / skip := true,
mimaFailOnNoPrevious := false
)
lazy val jsPrevVersions = Set.empty[String]
lazy val core = (crossProject(JSPlatform, JVMPlatform) in file ("core"))
.enablePlugins(BasicSettings, SiteSettingsPlugin)
.dependsOn(testing % "test")
.settings(Publish.settings: _*)
.settings(Release.settings: _*)
.settings(
name := "Log4s",
prevArtifacts,
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import ProblemFilters.exclude
/* import com.typesafe.tools.mima.core.ProblemFilters._ */
Seq(
/* These macros are not part of the runtime and are not a binary compatibility concern */
exclude[IncompatibleResultTypeProblem]("org.log4s.LoggerMacros.*"),
exclude[IncompatibleMethTypeProblem]("org.log4s.LoggerMacros.getLoggerImpl"),
/* These false positives happened in log4s-1.7.0 when we
* upgraded to Scala 2.12.8.
*
* See https://github.com/lightbend/mima/issues/388 */
exclude[DirectMissingMethodProblem]("org.log4s.MDC.+"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.++"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.-"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.--"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.andThen"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.clone"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.empty"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.filterNot"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.seq"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.updated"),
exclude[DirectMissingMethodProblem]("org.log4s.MDC.view"),
)
},
libraryDependencies ++= Seq (
slf4j,
logback % "test",
"org.scalacheck" %%% "scalacheck" % scalacheckVersion.value % "test",
),
libraryDependencies ++= {
if (isScala3(scalaVersion.value)) Seq.empty
else Seq(reflect.value % Provided)
},
Compile / unmanagedSourceDirectories ++= {
scalaBinaryVersion.value match {
case s if s.startsWith("2.") =>
Seq(baseDirectory.value / ".." / "shared" / "src" / "main" / "scala-2")
case s if s.startsWith("3") =>
Seq.empty
}
},
Compile / unmanagedSourceDirectories ++= {
scalaBinaryVersion.value match {
case "2.11" | "2.12" =>
Seq(baseDirectory.value / ".." / "shared" / "src" / "main" / "scala-oldcoll")
case _ =>
Seq(baseDirectory.value / ".." / "shared" / "src" / "main" / "scala-newcoll")
}
}
)
.jvmSettings(
libraryDependencies += ("org.scala-js" %% "scalajs-stubs" % scalajsStubsVersion % "provided").cross(CrossVersion.for3Use2_13),
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % scalatestVersion.value % Test,
"org.scalatestplus" %%% "scalacheck-1-15" % scalatestPlusScalacheckVersion.value % Test
),
prevVersions := {
/* I'm using the first & last version of each minor release rather than
* including every single patch-level update. */
def `2.11Versions` =
Set("1.0.3", "1.0.5",
"1.1.0", "1.1.5",
"1.2.0", "1.2.1",
"1.3.0")
def `2.12Versions` =
Set("1.3.3", "1.3.6",
"1.4.0",
"1.5.0",
"1.6.0", "1.6.1",
"1.7.0",
"1.8.0", "1.8.1")
def `2.13Versions` =
Set("1.8.2",
"1.9.0")
def DottyVersions =
Set.empty[String]
scalaBinaryVersion.value match {
case "2.11" => `2.11Versions` ++ `2.12Versions` ++ `2.13Versions` ++ DottyVersions
case "2.12" => `2.12Versions` ++ `2.13Versions` ++ DottyVersions
case "2.13" => `2.13Versions` ++ DottyVersions
case "3" => DottyVersions
case other =>
sLog.value.info(s"No known MIMA artifacts for: $other")
Set.empty
}
}
)
.jsSettings(jsOpts)
.jsSettings(
prevVersions := jsPrevVersions,
libraryDependencies ++= {
Seq(
"org.scalatest" %%% "scalatest" % scalatestVersion.value % Test,
"org.scalatestplus" %%% "scalacheck-1-15" % scalatestPlusScalacheckVersion.value % Test,
)
}
)
lazy val coreJS = core.js
lazy val coreJVM = core.jvm
lazy val testing = (crossProject(JSPlatform, JVMPlatform) in file ("testing"))
.enablePlugins(BasicSettings, SiteSettingsPlugin)
.settings(Publish.settings: _*)
.settings(Release.settings: _*)
.settings(
name := "Log4s Testing",
description := "Utilities to help with build-time unit tests for logging",
prevArtifacts,
libraryDependencies ++= Seq (
slf4j,
logback
)
)
.jvmSettings(
prevVersions := {
val `2.12Versions` = Set("1.5.0", "1.6.0", "1.6.1", "1.7.0", "1.8.0", "1.8.1")
val `2.13Versions` = Set("1.8.2")
val DottyVersions = Set.empty[String]
scalaBinaryVersion.value match {
case "2.11" | "2.12" => `2.12Versions` ++ `2.13Versions` ++ DottyVersions
case "2.13" => `2.13Versions` ++ DottyVersions
case "3" => DottyVersions
case other =>
Set.empty
}
}
)
.jsSettings(jsOpts)
.jsSettings(
prevVersions := jsPrevVersions
)
lazy val testingJS = testing.js
lazy val testingJVM = testing.jvm