-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathbuild.sbt
276 lines (253 loc) · 8.95 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import Settings._
def dataclassScalafixV = "0.2.0"
inThisBuild(List(
organization := "io.get-coursier",
homepage := Some(url("https://github.com/coursier/sbt-coursier")),
licenses := Seq("Apache 2.0" -> url("http://opensource.org/licenses/Apache-2.0")),
developers := List(
Developer(
"alexarchambault",
"Alexandre Archambault",
"",
url("https://github.com/alexarchambault")
)
),
semanticdbEnabled := true,
semanticdbVersion := "4.9.8",
scalafixDependencies += "net.hamnaberg" %% "dataclass-scalafix" % dataclassScalafixV,
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % "always"
))
Global / excludeLintKeys += scriptedBufferLog
Global / excludeLintKeys += scriptedLaunchOpts
def coursierVersion0 = "2.1.23"
def coursierDep = ("io.get-coursier" %% "coursier" % coursierVersion0)
.exclude("org.codehaus.plexus", "plexus-archiver")
.exclude("org.codehaus.plexus", "plexus-container-default")
def dataclassGen(data: Reference) = Def.taskDyn {
val root = (ThisBuild / baseDirectory).value.toURI.toString
val from = (data / Compile / sourceDirectory).value
val to = (Compile / sourceManaged).value
val outFrom = from.toURI.toString.stripSuffix("/").stripPrefix(root)
val outTo = to.toURI.toString.stripSuffix("/").stripPrefix(root)
(data / Compile / compile).value
Def.task {
(data / Compile / scalafix)
.toTask(s" --rules GenerateDataClass --out-from=$outFrom --out-to=$outTo")
.value
(to ** "*.scala").get
}
}
def lmIvy = Def.setting {
"org.scala-sbt" %% "librarymanagement-ivy" % {
scalaBinaryVersion.value match {
case "2.12" => "1.3.4"
case "2.13" => "1.7.0"
case _ => "2.0.0-alpha2"
}
}
}
lazy val preTest = taskKey[Unit]("prep steps before tests")
lazy val definitions = project
.in(file("modules/definitions"))
.disablePlugins(MimaPlugin)
.settings(
shared,
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++= Seq(
coursierDep,
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
lmIvy.value,
),
dontPublish,
)
// FIXME Ideally, we should depend on the same version of io.get-coursier.jniutils:windows-jni-utils that
// io.get-coursier::coursier depends on.
val jniUtilsVersion = "0.3.3"
lazy val `lm-coursier` = project
.in(file("modules/lm-coursier"))
.settings(
shared,
crossScalaVersions := Seq(scala212, scala213),
Mima.settings,
Mima.lmCoursierFilters,
libraryDependencies ++= Seq(
coursierDep,
"io.get-coursier" %% "coursier-sbt-maven-repository" % coursierVersion0,
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion,
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
// We depend on librarymanagement-ivy rather than just
// librarymanagement-core to handle the ModuleDescriptor passed
// to DependencyResolutionInterface.update, which is an
// IvySbt#Module (seems DependencyResolutionInterface.moduleDescriptor
// is ignored).
lmIvy.value,
"org.scalatest" %% "scalatest" % "3.2.19" % Test
),
Test / exportedProducts := {
(Test / preTest).value
(Test / exportedProducts).value
},
Test / preTest := {
(customProtocolForTest212 / publishLocal).value
(customProtocolForTest213 / publishLocal).value
(customProtocolJavaForTest / publishLocal).value
},
Compile / sourceGenerators += dataclassGen(definitions).taskValue,
)
lazy val `lm-coursier-shaded` = project
.in(file("modules/lm-coursier/target/shaded-module"))
.enablePlugins(ShadingPlugin)
.settings(
shared,
crossScalaVersions := Seq(scala212, scala213),
Mima.settings,
Mima.lmCoursierFilters,
Mima.lmCoursierShadedFilters,
Compile / sources := (`lm-coursier` / Compile / sources).value,
shadedModules ++= Set(
"io.get-coursier" %% "coursier",
"io.get-coursier" %% "coursier-sbt-maven-repository",
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier"
),
validNamespaces += "lmcoursier",
validEntries ++= Set(
// FIXME Ideally, we should just strip those from the resulting JAR…
"README", // from google-collections via plexus-archiver (see below)
// from plexus-util via plexus-archiver (see below)
"licenses/extreme.indiana.edu.license.TXT",
"licenses/javolution.license.TXT",
"licenses/thoughtworks.TXT",
"licenses/",
),
shadingRules ++= {
val toShade = Seq(
"coursier",
"dependency",
"org.fusesource",
"macrocompat",
"io.github.alexarchambault.windowsansi",
"concurrentrefhashmap",
// pulled by the plexus-archiver stuff that coursier-cache
// depends on for now… can hopefully be removed in the future
"com.google.common",
"org.apache.commons",
"org.apache.xbean",
"org.codehaus",
"org.iq80",
"org.tukaani",
"com.github.plokhotnyuk.jsoniter_scala",
"scala.cli",
"com.github.luben.zstd",
"javax.inject" // hope shading this is fine… It's probably pulled via plexus-archiver, that sbt shouldn't use anyway…
)
for (ns <- toShade)
yield ShadingRule.moveUnder(ns, "lmcoursier.internal.shaded")
},
libraryDependencies ++= Seq(
coursierDep,
"io.get-coursier" %% "coursier-sbt-maven-repository" % coursierVersion0,
"io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion,
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"org.scala-lang.modules" %% "scala-xml" % "2.3.0", // depending on that one so that it doesn't get shaded
"org.slf4j" % "slf4j-api" % "1.7.36", // depending on that one so that it doesn't get shaded either
lmIvy.value,
"org.scalatest" %% "scalatest" % "3.2.19" % Test
)
)
lazy val `sbt-coursier-shared` = project
.in(file("modules/sbt-coursier-shared"))
.disablePlugins(MimaPlugin)
.dependsOn(`lm-coursier`)
.settings(
plugin,
generatePropertyFile,
libraryDependencies += "com.lihaoyi" %% "utest" % "0.8.5" % Test,
testFrameworks += new TestFramework("utest.runner.Framework")
)
lazy val `sbt-coursier-shared-shaded` = project
.in(file("modules/sbt-coursier-shared/target/shaded-module"))
.disablePlugins(MimaPlugin)
.dependsOn(`lm-coursier-shaded`)
.settings(
plugin,
generatePropertyFile,
Compile / unmanagedSourceDirectories := (`sbt-coursier-shared` / Compile / unmanagedSourceDirectories).value
)
lazy val `sbt-lm-coursier` = project
.in(file("modules/sbt-lm-coursier"))
.enablePlugins(ScriptedPlugin)
.disablePlugins(MimaPlugin)
.dependsOn(`sbt-coursier-shared-shaded`)
.settings(
plugin,
sbtTestDirectory := (`sbt-coursier` / sbtTestDirectory).value,
scriptedDependencies := {
scriptedDependencies.value
// TODO Get those automatically
// (but shouldn't scripted itself handle that…?)
(`lm-coursier-shaded` / publishLocal).value
(`sbt-coursier-shared-shaded` / publishLocal).value
}
)
lazy val `sbt-coursier` = project
.in(file("modules/sbt-coursier"))
.enablePlugins(ScriptedPlugin)
.disablePlugins(MimaPlugin)
.dependsOn(`sbt-coursier-shared`)
.settings(
plugin,
scriptedDependencies := {
scriptedDependencies.value
// TODO Get dependency projects automatically
// (but shouldn't scripted itself handle that…?)
(`lm-coursier` / publishLocal).value
(`sbt-coursier-shared` / publishLocal).value
}
)
lazy val customProtocolForTest212 = project
.in(file("modules/custom-protocol-for-test-2-12"))
.settings(
sourceDirectory := file("modules/custom-protocol-for-test/src").toPath.toAbsolutePath.toFile,
scalaVersion := scala212,
organization := "org.example",
moduleName := "customprotocol-handler",
version := "0.1.0",
dontPublish
)
lazy val customProtocolForTest213 = project
.in(file("modules/custom-protocol-for-test-2-13"))
.settings(
sourceDirectory := file("modules/custom-protocol-for-test/src").toPath.toAbsolutePath.toFile,
scalaVersion := scala213,
organization := "org.example",
moduleName := "customprotocol-handler",
version := "0.1.0",
dontPublish
)
lazy val customProtocolJavaForTest = project
.in(file("modules/custom-protocol-java-for-test"))
.settings(
crossPaths := false,
organization := "org.example",
moduleName := "customprotocoljava-handler",
version := "0.1.0",
dontPublish
)
lazy val `sbt-coursier-root` = project
.in(file("."))
.disablePlugins(MimaPlugin)
.aggregate(
definitions,
`lm-coursier`,
`lm-coursier-shaded`,
`sbt-coursier`,
`sbt-coursier-shared`,
`sbt-coursier-shared-shaded`,
`sbt-lm-coursier`
)
.settings(
shared,
(publish / skip) := true
)
Global / onChangedBuildSource := ReloadOnSourceChanges