@@ -16,33 +16,46 @@ inThisBuild(
16
16
)
17
17
18
18
val scala213 = " 2.13.16"
19
- val scala3 = " 3.3.5"
19
+ val scala3 = " 3.3.6"
20
+ val jdkVersion = 11
20
21
val allScalaVersions = List (scala213, scala3)
21
22
val jvmScalaVersions = allScalaVersions
22
23
val jsScalaVersions = allScalaVersions
23
24
val nativeScalaVersions = allScalaVersions
24
25
25
26
val fs2Version = " 3.12.0"
26
27
28
+ ThisBuild / versionScheme := Some (" early-semver" )
27
29
ThisBuild / tpolecatOptionsMode := DevMode
28
30
29
31
val commonSettings = Seq (
30
32
libraryDependencies ++= Seq (
31
33
" com.disneystreaming" %%% " weaver-cats" % " 0.8.4" % Test
32
34
),
33
35
mimaPreviousArtifacts := Set (
34
- organization.value %%% name.value % " 0.0.7"
36
+ // organization.value %%% name.value % "0.0.7"
35
37
),
36
- scalacOptions += " -java-output-version:8"
38
+ scalacOptions ++= {
39
+ CrossVersion .partialVersion(scalaVersion.value) match {
40
+ case Some ((2 , _)) => Seq (s " -release: $jdkVersion" )
41
+ case _ => Seq (s " -java-output-version: $jdkVersion" )
42
+ }
43
+ },
44
+ )
45
+
46
+ val commonJvmSettings = Seq (
47
+ javacOptions ++= Seq (" --release" , jdkVersion.toString)
37
48
)
38
49
39
50
val core = projectMatrix
40
51
.in(file(" modules" ) / " core" )
41
52
.jvmPlatform(
42
53
jvmScalaVersions,
43
- Test / unmanagedSourceDirectories ++= Seq (
44
- (projectMatrixBaseDirectory.value / " src" / " test" / " scalajvm-native" ).getAbsoluteFile
45
- )
54
+ Seq (
55
+ Test / unmanagedSourceDirectories ++= Seq (
56
+ (projectMatrixBaseDirectory.value / " src" / " test" / " scalajvm-native" ).getAbsoluteFile
57
+ )
58
+ ) ++ commonJvmSettings
46
59
)
47
60
.jsPlatform(jsScalaVersions)
48
61
.nativePlatform(
@@ -56,13 +69,13 @@ val core = projectMatrix
56
69
name := " jsonrpclib-core" ,
57
70
commonSettings,
58
71
libraryDependencies ++= Seq (
59
- " com.github.plokhotnyuk.jsoniter-scala" %%% " jsoniter-scala-macros " % " 2.30.2"
72
+ " com.github.plokhotnyuk.jsoniter-scala" %%% " jsoniter-scala-circe " % " 2.30.2"
60
73
)
61
74
)
62
75
63
76
val fs2 = projectMatrix
64
77
.in(file(" modules" ) / " fs2" )
65
- .jvmPlatform(jvmScalaVersions)
78
+ .jvmPlatform(jvmScalaVersions, commonJvmSettings )
66
79
.jsPlatform(jsScalaVersions)
67
80
.nativePlatform(nativeScalaVersions)
68
81
.disablePlugins(AssemblyPlugin )
@@ -71,19 +84,97 @@ val fs2 = projectMatrix
71
84
name := " jsonrpclib-fs2" ,
72
85
commonSettings,
73
86
libraryDependencies ++= Seq (
74
- " co.fs2" %%% " fs2-core" % fs2Version
87
+ " co.fs2" %%% " fs2-core" % fs2Version,
88
+ " io.circe" %%% " circe-generic" % " 0.14.7" % Test
75
89
)
76
90
)
77
91
92
+ val smithy = projectMatrix
93
+ .in(file(" modules" ) / " smithy" )
94
+ .jvmPlatform(false )
95
+ .disablePlugins(AssemblyPlugin , MimaPlugin )
96
+ .enablePlugins(SmithyTraitCodegenPlugin )
97
+ .settings(
98
+ name := " jsonrpclib-smithy" ,
99
+ commonJvmSettings,
100
+ smithyTraitCodegenDependencies := List (Dependencies .alloy.core),
101
+ smithyTraitCodegenJavaPackage := " jsonrpclib" ,
102
+ smithyTraitCodegenNamespace := " jsonrpclib"
103
+ )
104
+
105
+ val smithyTests = projectMatrix
106
+ .in(file(" modules/smithy-tests" ))
107
+ .jvmPlatform(Seq (scala213))
108
+ .dependsOn(smithy)
109
+ .settings(
110
+ publish / skip := true ,
111
+ libraryDependencies ++= Seq (
112
+ " com.disneystreaming" %%% " weaver-cats" % " 0.8.4" % Test
113
+ )
114
+ )
115
+ .disablePlugins(MimaPlugin )
116
+
117
+ lazy val buildTimeProtocolDependency =
118
+ /** By default, smithy4sInternalDependenciesAsJars doesn't contain the jars in the "smithy4s" configuration. We have
119
+ * to add them manually - this is the equivalent of a "% Smithy4s"-scoped dependency.
120
+ *
121
+ * Ideally, this would be
122
+ * {{{
123
+ * (Compile / smithy4sInternalDependenciesAsJars) ++=
124
+ * Smithy4s / smithy4sInternalDependenciesAsJars).value.map(_.data)
125
+ * }}}
126
+ *
127
+ * but that doesn't work because the Smithy4s configuration doesn't extend from Compile so it doesn't have the
128
+ * `internalDependencyAsJars` setting.
129
+ */
130
+ Compile / smithy4sInternalDependenciesAsJars ++=
131
+ (smithy.jvm(autoScalaLibrary = false ) / Compile / fullClasspathAsJars).value.map(_.data)
132
+
133
+ val smithy4s = projectMatrix
134
+ .in(file(" modules" ) / " smithy4s" )
135
+ .jvmPlatform(jvmScalaVersions, commonJvmSettings)
136
+ .jsPlatform(jsScalaVersions)
137
+ .nativePlatform(Seq (scala3))
138
+ .disablePlugins(AssemblyPlugin )
139
+ .enablePlugins(Smithy4sCodegenPlugin )
140
+ .dependsOn(core)
141
+ .settings(
142
+ name := " jsonrpclib-smithy4s" ,
143
+ commonSettings,
144
+ mimaPreviousArtifacts := Set .empty,
145
+ libraryDependencies ++= Seq (
146
+ " com.disneystreaming.smithy4s" %%% " smithy4s-json" % smithy4sVersion.value
147
+ ),
148
+ buildTimeProtocolDependency
149
+ )
150
+
151
+ val smithy4sTests = projectMatrix
152
+ .in(file(" modules" ) / " smithy4s-tests" )
153
+ .jvmPlatform(jvmScalaVersions, commonJvmSettings)
154
+ .jsPlatform(jsScalaVersions)
155
+ .nativePlatform(Seq (scala3))
156
+ .disablePlugins(AssemblyPlugin )
157
+ .enablePlugins(Smithy4sCodegenPlugin )
158
+ .dependsOn(smithy4s, fs2 % Test )
159
+ .settings(
160
+ commonSettings,
161
+ publish / skip := true ,
162
+ libraryDependencies ++= Seq (
163
+ " io.circe" %%% " circe-generic" % " 0.14.7"
164
+ ),
165
+ buildTimeProtocolDependency
166
+ )
167
+
78
168
val exampleServer = projectMatrix
79
169
.in(file(" modules" ) / " examples/server" )
80
- .jvmPlatform(List (scala213))
170
+ .jvmPlatform(List (scala213), commonJvmSettings )
81
171
.dependsOn(fs2)
82
172
.settings(
83
173
commonSettings,
84
174
publish / skip := true ,
85
175
libraryDependencies ++= Seq (
86
- " co.fs2" %%% " fs2-io" % fs2Version
176
+ " co.fs2" %%% " fs2-io" % fs2Version,
177
+ " io.circe" %%% " circe-generic" % " 0.14.7"
87
178
)
88
179
)
89
180
.disablePlugins(MimaPlugin )
@@ -95,38 +186,93 @@ val exampleClient = projectMatrix
95
186
Seq (
96
187
fork := true ,
97
188
envVars += " SERVER_JAR" -> (exampleServer.jvm(scala213) / assembly).value.toString
98
- )
189
+ ) ++ commonJvmSettings
99
190
)
100
191
.disablePlugins(AssemblyPlugin )
101
192
.dependsOn(fs2)
102
193
.settings(
103
194
commonSettings,
104
195
publish / skip := true ,
105
196
libraryDependencies ++= Seq (
106
- " co.fs2" %%% " fs2-io" % fs2Version
197
+ " co.fs2" %%% " fs2-io" % fs2Version,
198
+ " io.circe" %%% " circe-generic" % " 0.14.7"
107
199
)
108
200
)
109
201
.disablePlugins(MimaPlugin )
110
202
203
+ val exampleSmithyShared = projectMatrix
204
+ .in(file(" modules" ) / " examples/smithyShared" )
205
+ .jvmPlatform(List (scala213), commonJvmSettings)
206
+ .dependsOn(smithy4s, fs2)
207
+ .enablePlugins(Smithy4sCodegenPlugin )
208
+ .settings(
209
+ commonSettings,
210
+ publish / skip := true ,
211
+ buildTimeProtocolDependency
212
+ )
213
+ .disablePlugins(MimaPlugin )
214
+
215
+ val exampleSmithyServer = projectMatrix
216
+ .in(file(" modules" ) / " examples/smithyServer" )
217
+ .jvmPlatform(List (scala213), commonJvmSettings)
218
+ .dependsOn(exampleSmithyShared)
219
+ .settings(
220
+ commonSettings,
221
+ publish / skip := true ,
222
+ libraryDependencies ++= Seq (
223
+ " co.fs2" %%% " fs2-io" % fs2Version
224
+ ),
225
+ assembly / assemblyMergeStrategy := {
226
+ case PathList (" META-INF" , " smithy" , _* ) => MergeStrategy .concat
227
+ case PathList (" jsonrpclib" , " package.class" ) => MergeStrategy .first
228
+ case PathList (" META-INF" , xs @ _* ) if xs.nonEmpty => MergeStrategy .discard
229
+ case x => MergeStrategy .first
230
+ }
231
+ )
232
+ .disablePlugins(MimaPlugin )
233
+
234
+ val exampleSmithyClient = projectMatrix
235
+ .in(file(" modules" ) / " examples/smithyClient" )
236
+ .jvmPlatform(
237
+ List (scala213),
238
+ Seq (
239
+ fork := true ,
240
+ envVars += " SERVER_JAR" -> (exampleSmithyServer.jvm(scala213) / assembly).value.toString
241
+ ) ++ commonJvmSettings
242
+ )
243
+ .dependsOn(exampleSmithyShared)
244
+ .settings(
245
+ commonSettings,
246
+ publish / skip := true ,
247
+ libraryDependencies ++= Seq (
248
+ " co.fs2" %%% " fs2-io" % fs2Version
249
+ )
250
+ )
251
+ .disablePlugins(MimaPlugin , AssemblyPlugin )
252
+
111
253
val root = project
112
254
.in(file(" ." ))
113
255
.settings(
114
256
publish / skip := true
115
257
)
116
258
.disablePlugins(MimaPlugin , AssemblyPlugin )
117
- .aggregate(List (core, fs2, exampleServer, exampleClient).flatMap(_.projectRefs): _* )
118
-
119
- // The core compiles are a workaround for https://github.com/plokhotnyuk/jsoniter-scala/issues/564
120
- // when we switch to SN 0.5, we can use `makeWithSkipNestedOptionValues` instead: https://github.com/plokhotnyuk/jsoniter-scala/issues/564#issuecomment-2787096068
121
- val compileCoreModules = {
122
- for {
123
- scalaVersionSuffix <- List (" " , " 3" )
124
- platformSuffix <- List (" " , " JS" , " Native" )
125
- task <- List (" compile" , " package" )
126
- } yield s " core $platformSuffix$scalaVersionSuffix/ $task"
127
- }.mkString(" ;" )
259
+ .aggregate(
260
+ List (
261
+ core,
262
+ fs2,
263
+ exampleServer,
264
+ exampleClient,
265
+ smithy,
266
+ smithyTests,
267
+ smithy4s,
268
+ smithy4sTests,
269
+ exampleSmithyShared,
270
+ exampleSmithyServer,
271
+ exampleSmithyClient
272
+ ).flatMap(_.projectRefs): _*
273
+ )
128
274
129
275
addCommandAlias(
130
276
" ci" ,
131
- s " $compileCoreModules ;test;scalafmtCheckAll;mimaReportBinaryIssues "
277
+ s " compile ;test;scalafmtCheckAll;mimaReportBinaryIssues"
132
278
)
0 commit comments