Skip to content

Commit df79ebf

Browse files
committed
fix #754: XML codec implemented
1 parent f97dd97 commit df79ebf

File tree

9 files changed

+1752
-1
lines changed

9 files changed

+1752
-1
lines changed

build.sbt

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ lazy val root = project
110110
zioSchemaAvro,
111111
zioSchemaBson,
112112
zioSchemaMsgPack,
113+
zioSchemaXmlJS,
114+
zioSchemaXmlJVM,
115+
zioSchemaXml.native,
113116
docs
114117
)
115118

@@ -296,6 +299,57 @@ lazy val zioSchemaProtobufJS = zioSchemaProtobuf.js
296299

297300
lazy val zioSchemaProtobufJVM = zioSchemaProtobuf.jvm
298301

302+
lazy val zioSchemaXml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
303+
.in(file("zio-schema-xml"))
304+
.dependsOn(zioSchema, zioSchemaDerivation, tests % "test->test")
305+
.settings(stdSettings("zio-schema-xml"))
306+
.settings(dottySettings)
307+
.settings(crossProjectSettings)
308+
.settings(buildInfoSettings("zio.schema.xml"))
309+
.settings(
310+
libraryDependencies ++= Seq(
311+
"org.scala-lang.modules" %%% "scala-xml" % scalaXmlVersion
312+
)
313+
)
314+
.jvmSettings(
315+
libraryDependencies ++= {
316+
if (scalaVersion.value.startsWith("3.")) {
317+
Seq(
318+
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.4.0" % Test,
319+
"javax.xml.bind" % "jaxb-api" % "2.3.1" % Test,
320+
"org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion % Test
321+
)
322+
} else {
323+
Seq(
324+
"org.scalaxb" %% "scalaxb" % "1.11.1" % Test,
325+
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.4.0" % Test,
326+
"javax.xml.bind" % "jaxb-api" % "2.3.1" % Test,
327+
"org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion % Test
328+
)
329+
}
330+
}
331+
)
332+
.nativeSettings(
333+
Test / fork := false,
334+
libraryDependencies ++= Seq(
335+
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion
336+
)
337+
)
338+
.jsSettings(
339+
libraryDependencies ++= Seq(
340+
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion,
341+
"io.github.cquiroz" %%% "scala-java-time-tzdb" % scalaJavaTimeVersion
342+
)
343+
)
344+
.settings(testDeps)
345+
.settings(
346+
mimaPreviousArtifacts := Set()
347+
)
348+
349+
lazy val zioSchemaXmlJS = zioSchemaXml.js
350+
lazy val zioSchemaXmlJVM = zioSchemaXml.jvm
351+
lazy val zioSchemaXmlNative = zioSchemaXml.native
352+
299353
lazy val zioSchemaThrift = project
300354
.in(file("zio-schema-thrift"))
301355
.dependsOn(zioSchema.jvm, zioSchemaDerivation.jvm, tests.jvm % "test->test")
@@ -480,7 +534,8 @@ lazy val docs = project
480534
zioSchemaAvro,
481535
zioSchemaBson,
482536
zioSchemaMsgPack,
483-
zioSchemaThrift
537+
zioSchemaThrift,
538+
zioSchemaXmlJVM
484539
)
485540
.enablePlugins(WebsitePlugin)
486541

project/BuildHelper.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ object BuildHelper {
4747
val thriftVersion = "0.22.0"
4848
val javaxAnnotationApiVersion = "3.0.0"
4949
val scalaJavaTimeVersion = "2.6.0"
50+
val scalaXmlVersion = "2.4.0"
5051

5152
def macroDefinitionSettings = Seq(
5253
scalacOptions += "-language:experimental.macros",

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8")
1212
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.10")
1313
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4")
1414
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.4.4")
15+
addSbtPlugin("org.scalaxb" % "sbt-scalaxb" % "1.12.1")
1516

1617
libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "3.0.1"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package zio.schema.codec
2+
3+
import scala.annotation.StaticAnnotation
4+
5+
object XmlAnnotations {
6+
7+
final case class name(name: String) extends StaticAnnotation
8+
9+
final case class namespace(uri: String) extends StaticAnnotation
10+
11+
final case class namespacePrefix(prefix: String) extends StaticAnnotation
12+
13+
final case class attribute() extends StaticAnnotation
14+
15+
final case class text() extends StaticAnnotation
16+
17+
final case class wrapped() extends StaticAnnotation
18+
19+
final case class collectionElement(name: String) extends StaticAnnotation
20+
21+
final case class cdata() extends StaticAnnotation
22+
23+
final case class omitEmpty() extends StaticAnnotation
24+
}

0 commit comments

Comments
 (0)