@@ -17,6 +17,7 @@ inThisBuild(
1717
1818val scala213 = " 2.13.16"
1919val scala3 = " 3.3.5"
20+ val jdkVersion = 11
2021val allScalaVersions = List (scala213, scala3)
2122val jvmScalaVersions = allScalaVersions
2223val jsScalaVersions = allScalaVersions
@@ -34,16 +35,27 @@ val commonSettings = Seq(
3435 mimaPreviousArtifacts := Set (
3536 organization.value %%% name.value % " 0.0.7"
3637 ),
37- scalacOptions += " -java-output-version:11"
38+ scalacOptions ++= {
39+ CrossVersion .partialVersion(scalaVersion.value) match {
40+ case Some ((2 , _)) => Seq (s " -target:jvm- $jdkVersion" )
41+ case _ => Seq (s " -java-output-version: $jdkVersion" )
42+ }
43+ }
44+ )
45+
46+ val commonJvmSettings = Seq (
47+ javacOptions ++= Seq (" --release" , jdkVersion.toString)
3848)
3949
4050val core = projectMatrix
4151 .in(file(" modules" ) / " core" )
4252 .jvmPlatform(
4353 jvmScalaVersions,
44- Test / unmanagedSourceDirectories ++= Seq (
45- (projectMatrixBaseDirectory.value / " src" / " test" / " scalajvm-native" ).getAbsoluteFile
46- )
54+ Seq (
55+ Test / unmanagedSourceDirectories ++= Seq (
56+ (projectMatrixBaseDirectory.value / " src" / " test" / " scalajvm-native" ).getAbsoluteFile
57+ )
58+ ) ++ commonJvmSettings
4759 )
4860 .jsPlatform(jsScalaVersions)
4961 .nativePlatform(
@@ -63,7 +75,7 @@ val core = projectMatrix
6375
6476val fs2 = projectMatrix
6577 .in(file(" modules" ) / " fs2" )
66- .jvmPlatform(jvmScalaVersions)
78+ .jvmPlatform(jvmScalaVersions, commonJvmSettings )
6779 .jsPlatform(jsScalaVersions)
6880 .nativePlatform(nativeScalaVersions)
6981 .disablePlugins(AssemblyPlugin )
@@ -78,36 +90,52 @@ val fs2 = projectMatrix
7890
7991val smithy = projectMatrix
8092 .in(file(" modules" ) / " smithy" )
81- .jvmPlatform(jvmScalaVersions)
82- .jsPlatform(jsScalaVersions)
83- .nativePlatform(nativeScalaVersions)
93+ .jvmPlatform(false )
8494 .disablePlugins(AssemblyPlugin , MimaPlugin )
95+ .enablePlugins(SmithyTraitCodegenPlugin )
8596 .settings(
86- name := " jsonrpclib-smithy"
87- )
97+ name := " jsonrpclib-smithy" ,
98+ commonJvmSettings
99+ )
100+
101+ lazy val buildTimeProtocolDependency =
102+ /** By default, smithy4sInternalDependenciesAsJars doesn't contain the jars in the "smithy4s" configuration. We have
103+ * to add them manually - this is the equivalent of a "% Smithy4s"-scoped dependency.
104+ *
105+ * Ideally, this would be
106+ * {{{
107+ * (Compile / smithy4sInternalDependenciesAsJars) ++=
108+ * Smithy4s / smithy4sInternalDependenciesAsJars).value.map(_.data)
109+ * }}}
110+ *
111+ * but that doesn't work because the Smithy4s configuration doesn't extend from Compile so it doesn't have the
112+ * `internalDependencyAsJars` setting.
113+ */
114+ Compile / smithy4sInternalDependenciesAsJars ++=
115+ (smithy.jvm(autoScalaLibrary = false ) / Compile / fullClasspathAsJars).value.map(_.data)
88116
89117val smithy4s = projectMatrix
90118 .in(file(" modules" ) / " smithy4s" )
91- .jvmPlatform(jvmScalaVersions)
119+ .jvmPlatform(jvmScalaVersions, commonJvmSettings )
92120 .jsPlatform(jsScalaVersions)
93121 .nativePlatform(Seq (scala3))
94122 .disablePlugins(AssemblyPlugin )
95123 .enablePlugins(Smithy4sCodegenPlugin )
96124 .dependsOn(core)
97- .dependsOn(smithy)
98125 .settings(
99126 name := " jsonrpclib-smithy4s" ,
100127 commonSettings,
101128 mimaPreviousArtifacts := Set .empty,
102129 libraryDependencies ++= Seq (
103130 " co.fs2" %%% " fs2-core" % fs2Version,
104131 " com.disneystreaming.smithy4s" %%% " smithy4s-json" % smithy4sVersion.value
105- )
132+ ),
133+ buildTimeProtocolDependency
106134 )
107135
108136val exampleServer = projectMatrix
109137 .in(file(" modules" ) / " examples/server" )
110- .jvmPlatform(List (scala213))
138+ .jvmPlatform(List (scala213), commonJvmSettings )
111139 .dependsOn(fs2)
112140 .settings(
113141 commonSettings,
@@ -125,7 +153,7 @@ val exampleClient = projectMatrix
125153 Seq (
126154 fork := true ,
127155 envVars += " SERVER_JAR" -> (exampleServer.jvm(scala213) / assembly).value.toString
128- )
156+ ) ++ commonJvmSettings
129157 )
130158 .disablePlugins(AssemblyPlugin )
131159 .dependsOn(fs2)
@@ -140,18 +168,19 @@ val exampleClient = projectMatrix
140168
141169val exampleSmithyShared = projectMatrix
142170 .in(file(" modules" ) / " examples/smithyShared" )
143- .jvmPlatform(List (scala213))
171+ .jvmPlatform(List (scala213), commonJvmSettings )
144172 .dependsOn(smithy4s, fs2)
145173 .enablePlugins(Smithy4sCodegenPlugin )
146174 .settings(
147175 commonSettings,
148- publish / skip := true
176+ publish / skip := true ,
177+ buildTimeProtocolDependency
149178 )
150179 .disablePlugins(MimaPlugin )
151180
152181val exampleSmithyServer = projectMatrix
153182 .in(file(" modules" ) / " examples/smithyServer" )
154- .jvmPlatform(List (scala213))
183+ .jvmPlatform(List (scala213), commonJvmSettings )
155184 .dependsOn(exampleSmithyShared)
156185 .settings(
157186 commonSettings,
@@ -175,7 +204,7 @@ val exampleSmithyClient = projectMatrix
175204 Seq (
176205 fork := true ,
177206 envVars += " SERVER_JAR" -> (exampleSmithyServer.jvm(scala213) / assembly).value.toString
178- )
207+ ) ++ commonJvmSettings
179208 )
180209 .dependsOn(exampleSmithyShared)
181210 .settings(
0 commit comments