-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sbt
227 lines (210 loc) · 9.2 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
import Dependencies._
import org.scalafmt.sbt.ScalafmtPlugin.autoImport.scalafmtOnCompile
import sbt.Keys.{semanticdbEnabled, semanticdbVersion, versionScheme}
initialize ~= { _ =>
if (sys.props.getOrElse("java.specification.version", "0").toDouble < 11.0) {
throw new IllegalArgumentException(
"Project must be built with java version 11 or higher. Current java version will cause failure of compilation.")
}
}
lazy val targetScalaVersions = List(scalaVersion213, scalaVersion212)
lazy val testAgainstScalaVersions =
targetScalaVersions ++ List("2.12.16", "2.12.17", "2.12.18")
ThisBuild / scalaVersion := targetScalaVersions.head
ThisBuild / organization := "org.virtuslab.ash"
ThisBuild / organizationName := "VirtusLab"
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / homepage := Some(url("https://github.com/VirtusLab/akka-serialization-helper"))
ThisBuild / licenses := List("MIT License" -> url("https://github.com/VirtusLab/akka-serialization-helper/blob/main/LICENSE"))
ThisBuild / developers := List(
Developer("MarconZet", "Marcin Złakowski", "[email protected]", url("https://github.com/MarconZet")),
Developer("LukaszKontowski", "Łukasz Kontowski", "[email protected]", url("https://github.com/LukaszKontowski")),
Developer("PawelLipski", "Paweł Lipski", "[email protected]", url("https://github.com/PawelLipski")))
sonatypeProfileName := "org.virtuslab"
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.9.3"
ThisBuild / resolvers += Resolver.ApacheMavenSnapshotsRepo
lazy val commonSettings = Seq(
sonatypeProfileName := "org.virtuslab",
scalafmtOnCompile := true,
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:_",
"-Xlog-reflective-calls",
"-Xlint:_",
"-Ybackend-parallelism",
"8",
"-Ywarn-dead-code",
"-Ywarn-unused",
"-unchecked",
"-Xfatal-warnings"),
libraryDependencies ++= commonDeps)
// As usage of https://github.com/pathikrit/better-files and https://github.com/spray/spray-json
// has been added to the runtime logic of dump-persistence-schema-compiler-plugin -
// this dependencies have to be provided within a fat jar when ASH gets published.
// For reasons described in https://github.com/sbt/sbt/issues/2255 - without using fat-jar we would have java.lang.NoClassDefFoundErrors
lazy val assemblySettings = Seq(
packageBin / publishArtifact := false, // we want to publish fat jar
Compile / packageBin / artifactPath := crossTarget.value / "packageBinPlaceholder.jar", // this ensures that normal jar doesn't override fat jar
assembly / assemblyMergeStrategy := {
case PathList(
"scala",
"annotation",
"nowarn.class" | "nowarn$.class"
) => // scala-collection-compat duplicates no-warn.class, as it was added to scala 2.12 after its release
MergeStrategy.first
case x =>
(assembly / assemblyMergeStrategy).value.apply(x)
},
Compile / assembly / artifact := {
val art = (Compile / assembly / artifact).value
art.withClassifier(None)
},
// Warning: this is a default name for packageBin artefact. Without explicit rename of packageBin will result in race condition
assembly / assemblyJarName := s"${name.value}_${scalaBinaryVersion.value}-${version.value}.jar",
addArtifact(Compile / assembly / artifact, assembly))
publish / skip := true
lazy val scalaVersionAxis = settingKey[Option[String]]("Project scala version")
lazy val circeAkkaSerializer = (projectMatrix in file("circe-akka-serializer"))
.settings(name := "circe-akka-serializer")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.settings(libraryDependencies ++= Seq(
akkaActor % Provided,
akkaActorTyped % Provided,
akkaTestKitTyped % Test,
akkaStream % Provided,
circeCore,
circeParser,
circeGeneric,
circeGenericExtras,
reflections,
scalaCollectionCompat))
.settings(
resolvers ++= Resolver.sonatypeOssRepos("releases"),
libraryDependencies ++=
CrossVersion
.partialVersion(scalaVersion.value)
.map {
case (2, 13) =>
Seq(scalaReflect % scalaVersion213)
case (2, 12) =>
Seq(
scalaReflect % scalaVersion212,
compilerPlugin(("org.scalamacros" % "paradise" % "2.1.1" % Test).cross(CrossVersion.full))
) // Add macro annotations to scala 2.12
}
.get,
Test / scalacOptions ++= CrossVersion
.partialVersion(scalaVersion.value)
.map {
case (2, 13) =>
Seq(
"-Ymacro-annotations", // Semiautomatic circe codec derivation uses macro annotations.
"-Xlint:-byname-implicit" // Not disabling byname-implicit raises warnings on code generated by Circe macros
)
case (2, 12) =>
Seq.empty
}
.get)
.jvmPlatform(scalaVersions = targetScalaVersions)
lazy val annotation = (projectMatrix in file("annotation"))
.settings(name := "annotation")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.jvmPlatform(scalaVersions = targetScalaVersions)
lazy val serializabilityCheckerCompilerPlugin = (projectMatrix in file("serializability-checker-compiler-plugin"))
.settings(name := "serializability-checker-compiler-plugin")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.settings(resolvers ++= Resolver.sonatypeOssRepos("snapshots"))
.settings(
libraryDependencies ++= {
CrossVersion
.partialVersion(scalaVersion.value)
.map {
case (2, 13) => scalaPluginDeps213
case (2, 12) => scalaPluginDeps212
}
.getOrElse(Seq.empty)
},
libraryDependencies ++= Seq(
akkaActor % Test,
akkaActorTyped % Test,
akkaPersistenceTyped % Test,
akkaProjections % Test,
betterFiles % Test,
akkaGrpc % Test,
akkaHttpCors % Test))
.dependsOn(annotation)
.jvmPlatform(scalaVersions = targetScalaVersions)
lazy val codecRegistrationCheckerCompilerPlugin = (projectMatrix in file("codec-registration-checker-compiler-plugin"))
.settings(name := "codec-registration-checker-compiler-plugin")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.settings(
libraryDependencies ++= {
CrossVersion
.partialVersion(scalaVersion.value)
.map {
case (2, 13) => scalaPluginDeps213
case (2, 12) => scalaPluginDeps212
}
.getOrElse(Seq.empty)
},
libraryDependencies += betterFiles % Test)
.dependsOn(annotation, circeAkkaSerializer % Test)
.jvmPlatform(scalaVersions = targetScalaVersions)
lazy val sbtAkkaSerializationHelper = (project in file("sbt-akka-serialization-helper"))
.enablePlugins(SbtPlugin)
.settings(name := "sbt-akka-serialization-helper")
.settings(commonSettings)
.settings(
pluginCrossBuild / sbtVersion := "1.2.8",
scalaVersion := scalaVersion212,
libraryDependencies ++= Seq(sprayJson, circeCore, circeGeneric, circeYaml, betterFiles),
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq(
"-Xmx1024M",
"-Dplugin.version=" + version.value,
"-Dcompiler-plugin.version=" + (dumpPersistenceSchemaCompilerPlugin.componentProjects.head / version).value)
},
scriptedDependencies := { // publishing compiler plugin locally for testing
scriptedDependencies.value
// this can't be abstracted to function because of the limitation of sbt macro expansion
// both head and tail.head must be published because they are separate projects, one for scala 2.13, one for 2.12
(annotation.projectRefs.head / publishLocal).value
(annotation.projectRefs.tail.head / publishLocal).value
(circeAkkaSerializer.projectRefs.head / publishLocal).value
(circeAkkaSerializer.projectRefs.tail.head / publishLocal).value
(codecRegistrationCheckerCompilerPlugin.projectRefs.head / publishLocal).value
(codecRegistrationCheckerCompilerPlugin.projectRefs.tail.head / publishLocal).value
(dumpPersistenceSchemaCompilerPlugin.projectRefs.head / publishLocal).value
(dumpPersistenceSchemaCompilerPlugin.projectRefs.tail.head / publishLocal).value
(serializabilityCheckerCompilerPlugin.projectRefs.head / publishLocal).value
(serializabilityCheckerCompilerPlugin.projectRefs.tail.head / publishLocal).value
},
scriptedBufferLog := false)
lazy val dumpPersistenceSchemaCompilerPlugin = (projectMatrix in file("dump-persistence-schema-compiler-plugin"))
.enablePlugins(AssemblyPlugin)
.settings(name := "dump-persistence-schema-compiler-plugin")
.settings(commonSettings)
.settings(crossScalaVersions := testAgainstScalaVersions)
.settings(
libraryDependencies ++= {
CrossVersion
.partialVersion(scalaVersion.value)
.map {
case (2, 13) => scalaPluginDeps213
case (2, 12) => scalaPluginDeps212
}
.getOrElse(Seq.empty)
},
libraryDependencies ++= Seq(sprayJson, betterFiles, akkaActorTyped % Test, akkaPersistenceTyped % Test))
.settings(assemblySettings: _*)
.jvmPlatform(scalaVersions = targetScalaVersions)