-
Notifications
You must be signed in to change notification settings - Fork 76
/
build.sbt
218 lines (192 loc) · 6.88 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
import com.softwaremill.SbtSoftwareMillCommon.commonSmlBuildSettings
import com.softwaremill.Publish.{updateDocs, ossPublishSettings}
import com.softwaremill.UpdateVersionInDocs
import sbt._
import sbt.Keys._
excludeLintKeys in Global ++= Set(ideSkipProject)
val scala2_12 = "2.12.20"
val scala2_13 = "2.13.15"
val scala2 = List(scala2_12, scala2_13)
val scala3 = "3.3.4"
val scala2And3Versions = scala2 :+ scala3
val ideScalaVersion = scala3
def compilerLibrary(scalaVersion: String) = {
if (scalaVersion == scala3) {
Seq("org.scala-lang" %% "scala3-compiler" % scalaVersion)
} else {
Seq("org.scala-lang" % "scala-compiler" % scalaVersion)
}
}
def reflectLibrary(scalaVersion: String) = {
if (scalaVersion == scala3) {
Seq.empty
} else {
Seq("org.scala-lang" % "scala-reflect" % scalaVersion)
}
}
val versionSpecificScalaSources = {
Compile / unmanagedSourceDirectories := {
val current = (Compile / unmanagedSourceDirectories).value
val sv = (Compile / scalaVersion).value
val baseDirectory = (Compile / scalaSource).value
val suffixes = CrossVersion.partialVersion(sv) match {
case Some((2, 13)) => List("2", "2.13+")
case Some((2, _)) => List("2", "2.13-")
case Some((3, _)) => List("3")
case _ => Nil
}
val versionSpecificSources = suffixes.map(s => new File(baseDirectory.getAbsolutePath + "-" + s))
versionSpecificSources ++ current
}
}
val commonSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq(
organization := "com.softwaremill.macwire",
ideSkipProject := (scalaVersion.value != ideScalaVersion) || thisProjectRef.value.project.contains("JS"),
bspEnabled := !ideSkipProject.value,
scalacOptions ~= (_.filterNot(Set("-Wconf:cat=other-match-analysis:error"))) // doesn't play well with macros
)
val testSettings = commonSettings ++ Seq(
publishArtifact := false,
scalacOptions ++= Seq("-Ywarn-dead-code"),
// Otherwise when running tests in sbt, the macro is not visible
// (both macro and usages are compiled in the same compiler run)
Test / fork := true
)
val tagging = "com.softwaremill.common" %% "tagging" % "2.3.5"
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
val javassist = "org.javassist" % "javassist" % "3.30.2-GA"
val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.6.21"
val pekkoActor = "org.apache.pekko" %% "pekko-actor" % "1.1.2"
val javaxInject = "javax.inject" % "javax.inject" % "1"
val cats = "org.typelevel" %% "cats-core" % "2.12.0"
val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.7"
lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(name := "macwire", publishArtifact := false)
.aggregate(
List(
util,
macros,
proxy,
tests,
tests2,
testUtil,
utilTests,
macrosAkka,
macrosPekko,
macrosAkkaTests,
macrosPekkoTests,
macrosAutoCats,
macrosAutoCatsTests
).flatMap(_.projectRefs): _*
)
lazy val util = projectMatrix
.in(file("util"))
.settings(libraryDependencies += tagging)
.settings(commonSettings)
.jvmPlatform(scalaVersions = scala2And3Versions)
.jsPlatform(scalaVersions = scala2And3Versions)
.nativePlatform(scalaVersions = scala2And3Versions)
lazy val macros = projectMatrix
.in(file("macros"))
.settings(commonSettings)
.settings(
libraryDependencies ++= reflectLibrary(scalaVersion.value),
versionSpecificScalaSources
)
.dependsOn(util % "provided")
.jvmPlatform(scalaVersions = scala2And3Versions)
.jsPlatform(scalaVersions = scala2And3Versions)
.nativePlatform(scalaVersions = scala2And3Versions)
lazy val proxy = projectMatrix
.in(file("proxy"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(javassist, scalatest % Test),
compileOrder := CompileOrder.JavaThenScala,
javaOptions += "--add-opens java.base/java.lang=ALL-UNNAMED"
)
.dependsOn(macros % Test)
.jvmPlatform(scalaVersions = scala2And3Versions)
lazy val testUtil = projectMatrix
.in(file("test-util"))
.settings(testSettings)
.settings(
libraryDependencies ++= Seq(
scalatest,
javaxInject
) ++ compilerLibrary(scalaVersion.value)
)
.jvmPlatform(
scalaVersions = scala2And3Versions
)
.jvmPlatform(scalaVersions = scala2)
lazy val tests = projectMatrix
.in(file("tests"))
.settings(testSettings)
.dependsOn(macros % "provided", testUtil % Test, proxy)
.jvmPlatform(scalaVersions = scala2And3Versions)
lazy val utilTests = projectMatrix
.in(file("util-tests"))
.settings(testSettings)
.dependsOn(macros % "provided", util % Test, testUtil % Test)
.jvmPlatform(scalaVersions = scala2And3Versions)
// The tests here are that the tests compile.
lazy val tests2 = projectMatrix
.in(file("tests2"))
.settings(testSettings)
.settings(libraryDependencies += scalatest % Test)
.dependsOn(util, macros % "provided", proxy)
.jvmPlatform(scalaVersions = scala2And3Versions)
lazy val macrosAkka = projectMatrix
.in(file("macrosAkka"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(akkaActor % "provided"))
.dependsOn(macros)
.jvmPlatform(scalaVersions = scala2)
.jsPlatform(scalaVersions = scala2)
lazy val macrosPekko = projectMatrix
.in(file("macrosPekko"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(pekkoActor % "provided"))
.dependsOn(macros)
.jvmPlatform(scalaVersions = scala2)
.jsPlatform(scalaVersions = scala2)
lazy val macrosAkkaTests = projectMatrix
.in(file("macrosAkkaTests"))
.settings(
// Needed to avoid cryptic EOFException crashes in forked tests in Travis
// example failure: https://travis-ci.org/adamw/macwire/builds/191382122
// see: https://github.com/travis-ci/travis-ci/issues/3775
javaOptions += "-Xmx1G"
)
.settings(testSettings)
.settings(libraryDependencies ++= Seq(scalatest, tagging, akkaActor))
.dependsOn(macrosAkka, testUtil)
.jvmPlatform(scalaVersions = scala2)
lazy val macrosPekkoTests = projectMatrix
.in(file("macrosPekkoTests"))
.settings(
// Needed to avoid cryptic EOFException crashes in forked tests in Travis
// example failure: https://travis-ci.org/adamw/macwire/builds/191382122
// see: https://github.com/travis-ci/travis-ci/issues/3775
javaOptions += "-Xmx1G"
)
.settings(testSettings)
.settings(libraryDependencies ++= Seq(scalatest, tagging, pekkoActor))
.dependsOn(macrosPekko, testUtil)
.jvmPlatform(scalaVersions = scala2)
lazy val macrosAutoCats = projectMatrix
.in(file("macrosAutoCats"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(catsEffect, cats))
.dependsOn(macros)
.jvmPlatform(scalaVersions = scala2)
.jsPlatform(scalaVersions = scala2)
lazy val macrosAutoCatsTests = projectMatrix
.in(file("macrosAutoCatsTests"))
.settings(testSettings)
.settings(libraryDependencies ++= Seq(scalatest, catsEffect, tagging))
.dependsOn(macrosAutoCats, testUtil)
.jvmPlatform(scalaVersions = scala2)