scalaxb 1.12.5
updates
-
fix: Parse named
xs:anyTypeelements by name by @thijsnissen in #718

scalaxb is an XML data-binding tool for Scala that supports W3C XML Schema (xsd) and Web Services Description Language (wsdl) as the input file.
Many things still may not work. I’d appreciate if you could run it against your favorite xsd file and let me know the result.
fix: Parse named xs:anyType elements by name by @thijsnissen in #718
fix: Fixes generated code on Scala 3 by @mrdziuban in #697
fix: Adds the ability to specify --jaxb-package that was missing for mvn-scalaxb by @lciolecki in #699
sbt-scalaxb 1.12.3 is cross published to sbt 1.x and 2.x.
scalaxb 1.12.2 is released
scalaxb 1.12.2 adds support for Dispatch 2.x, contributed by @urwithsumit in #677
scalaxb 1.12.1 is released.
Continuing the theme from scalaxb 1.12.0, scalaxb 1.12.1 improves the code generation for Scala 3. In #654 Matt Dziuban contributed a fix to stop passing in an implicit parameter explicitly, which started to fail to compile on Scala 3.5.0 without using marker.
In #661 @eed3si9n further improved the Scala 3 compatibility enough to pass -Xfatal-warnings with basic usages on LTS Scala 3.3.3 and non-LTS Scala 3.5.0:
xs: _* to xs*self: A with B => to self: A & B =>value startsWith "{" to Java-style value.startsWith("{") notation_ to Java-style null_ to ?Full release note is at https://github.com/eed3si9n/scalaxb/releases/tag/v1.12.1
scalaxb 1.12.0 supports choosing javax or jakarta for jaxb package name
Compile / scalaxbJaxbPackage := JaxbPackage.Jakarta
This was contributed by @mrdziuban in #613
ClassTag instead of Manifest by @xuwei-k in #608httpclients_http4s_0_22.scala.template by @kevin-lee in #601Full Changelog: https://github.com/eed3si9n/scalaxb/compare/v1.11.0...v1.11.1
scalaxb 1.11.0 adds support for http4s client generation.
ThisBuild / organization := "com.example"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.10"
ThisBuild / scalaxbPackageName := "generated"
ThisBuild / scalaxbGenerateDispatchClient := false
ThisBuild / scalaxbGenerateHttp4sClient := true
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "2.1.0"
lazy val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "2.2.0"
lazy val jaxbApi = "javax.xml.bind" % "jaxb-api" % "2.3.0"
lazy val emberClient= "org.http4s" %% "http4s-ember-client" % "0.23.18"
lazy val root = (project in file("."))
.enablePlugins(ScalaxbPlugin)
.settings(
name := "soap",
libraryDependencies ++= Seq(scalaXml, scalaParser, jaxbApi, emberClient),
)
This was contributed by Darren Gibson (@zarthross) in #596.
Full Changelog: https://github.com/eed3si9n/scalaxb/compare/v1.9.0...v1.9.1
scalaxb.scala #584 by @bodduv$ sbt new eed3si9n/scalaxb.g8
Adds scalaxbUseLists setting to generate List[A] instead of Seq[A] #526 by @pgrandjean
Fixes code generation to avoid multi-arg infix syntax #531 by @margussipria
Splits generated fromString method for big enums that would otherwise not compile #517 by @LolHens
Fixes big decimal formatting in toXML according to XML Schema #505 by @tOverney
Fixes big decimal formatting according to XML Schema #483 by @danslapman
Fixes equals called on a String and Option[String] #485 by @lespea
Fixes one-way SOAP call #493 by @danslapman
ExecutionContext parameter is added to all methods returning Future[A], instead of hardcoding a execution context. #482 inspired by #407.Starting scalaxb 1.7.0, an explicit import of ExecutionContext would be required as follows:
import scala.concurrent.ExecutionContext.Implicits._
scalaxb 1.7.0 adds option to encode symbols.
lazy val scalaxbCapitalizeWords = settingKey[Boolean]("Attempts to capitalize class and attribute names to match the CamelCase convention")
lazy val scalaxbSymbolEncodingStrategy = settingKey[SymbolEncodingStrategy.Value]("Specifies the strategy to encode non-identifier characters in generated class names")
object SymbolEncodingStrategy extends Enumeration {
val Discard = Value("discard")
val SymbolName = Value("symbol-name")
val UnicodePoint = Value("unicode-point")
val DecimalAscii = Value("decimal-ascii")
val Legacy151 = Value("legacy-1.5.1")
}
anyAttribute #470 by @hosamalyscalaxbEnumNameMaxLength for enum name length #480 by @mrdziuban"u93". #415 by @varneracAdds Gigahorse support. #413 by @alexdupre
Adds Scala 2.12 cross building. #413/#419 by @alexdupre and @dwijnand
00 in xsd:byte. #388 by @anatoliykmetyuk--mutable option to generate mutable case classes. See below.xs:any. #389 by @anatoliykmetyuk--autopackages option to pick package names automatically. #391 by @anatoliykmetyuk--visitor option to generate a Visitor for traversing over the generated case classes. #392 by @anatoliykmetyuksbt-scalaxb for scalaxb 1.5.0 is changed to an auto plugin.
Instead of adding scalaxbSettings and defining sourceGenerators in Compile,
enable ScalaxbPlugin instead. All other setting/task keys will be prefixed with “scalaxb”.
For example, packageName will now be called scalaxbPackageName.
Before:
import ScalaxbKeys._
lazy val root = (project in file(".")).
settings(
name := "foo-project").
settings(scalaxbSettings).
settings(
sourceGenerators in Compile += (scalaxb in Compile).taskValue,
packageName in (Compile, scalaxb) := "generated"
// packageNames in (Compile, scalaxb) := Map(uri("http://something/") -> "something"),
// logLevel in (Compile, scalaxb) := Level.Debug
)
After:
lazy val root = (project in file(".")).
enablePlugins(ScalaxbPlugin).
settings(
name := "foo-project",
scalaxbPackageName in (Compile, scalaxb) := "generated"
// scalaxbAutoPackages in (Compile, scalaxb) := true
)
scalaxb 1.5.0 adds an option to generate mutable case classes.
case class Address(var name: String,
var street: String,
var city: String)
In sbt-scalaxb, this can be enabled as:
lazy val root = (project in file(".")).
enablePlugins(ScalaxbPlugin).
settings(
name := "foo-project",
scalaxbPackageName in (Compile, scalaxb) := "generated",
scalaxbGenerateMutable in (Compile, scalaxb) := true
)
Huge thanks to everyone who has helped to improve scalaxb by sending pull requests and reporting bugs!
According to git shortlog -sn --no-merges 1.4.1..release/1.5.0, the following people contributed to this release: Anatoliy Kmetyuk (@anatoliykmetyuk), Eugene Yokota (@eed3si9n), Andre Van Delft (@AndreVanDelft), Jan-Kees van Andel (@jankeesvanandel), Joshua Reese (@joshlreese), and Mateusz Kołodziejczyk (@coutoPL).
defaultDispatchVersion is bumped up to it. #352 by @DustinChaloupkaHere’s a list of users who are using scalaxb, or have at some point.
Non-blocking SOAP feature was also contributed by @hoff2 from Banno.
Scoozie: Creating Big Data Workflows at Klout
Additionally, we would like to provide a shout-out to a great open-source project, scalaxb, an sbt plugin that takes .xsd files and creates matching Scala case classes. Scoozie populates these case classes, which are then automatically converted to XML by scalaxb. This plugin saved a lot of headache in the actual process of conversion to XML.
Dispatch forms the foundation of an in-house SOAP client at Novus together with scalaxb. Thanks to these tools our standard response to “Can you do SOAP?” is “Bring it on!” instead of “Ew, what’s this on my shoe?!”
Using Salat with scalaxb generated classes:
scalaxb generates Scala case classes from XSDs and generates supporting helpers for going back and forth from case class to XML. Salat provides an interface to MongoDB based on case classes.
There are a couple hurdles, but both project owners have taken our suggestions seriously, and have smoothed out quite a few bumps.
requestTimeout and connectionTimeout to DispatchHttpClients. #304 by @eed3si9n--no-dispatch-client option (generateDispatchClient := false). #322 by @liff--dispatch-as option (generateDispatchAs := true) for Dispatch’s Http(request > as.scalaxb[A]) support. #332 by @arkadius--ignore-unknown option (ignoreUnknown := true) to ignore unknown XML elements, as well as order in which they are arrived. #310 by @jet-black--no-varargs option to use Seq instead of the varargs. #292/#309 by @lbruand and @Erwan56CompilerMatcher. #307 by @joesciiThe code generated by scalaxb 1.4.0 should no longer generate compiler warnings.
-Xfatal-warnings during the integration tests. #343 by @eed3si9nA huge thanks to everyone who has helped to improve scalaxb by reporting bugs and sending pull requests!
According to git shortlog -sn --no-merges 1.3.0..release/1.4.0 ten people contributed to this release: Eugene Yokota (@eed3si9n), @jet-black, Olli Helenius (@liff), Lucas Bruand (@lbruand), Markus Klink (@justjoheinz), Carl Livermore (@carl297r), Arek Burdach (@arkadius), Joe Barnes (@joescii), @Erwan56, Roman Parykin (@donderom).
faultactor a String. #268 by @rubbishattributes field to handle all attributes. #286nillable fault support. #284http instances lazy. #279 by @rubbishtoString methods for faults. #278Starting scalaxb 1.3.0, the generated code will be >22 by default. In addition, all attributes will be handled via attributes field.
To bring back the older behavior:
contentsSizeLimit in (Compile, scalaxb) := 20
namedAttributes in (Compile, scalaxb) := true
Related, 1.3.0 fixes attribute’s default value handling #288.
Thanks to YourKit for supporting scalaxb! YourKit Java Profiler works great for profiling Scala applications.
Starting scalaxb 1.2.0 it supports Scala 2.11.x. Since Scala 2.11 modularizes XML and parser combinators, it requires additional setup on your part. Here’s using sbt 0.13’s multi-project build.sbt syntax:
import ScalaxbKeys._
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.2"
lazy val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1"
lazy val dispatchV = "0.11.2" // change this to appropriate dispatch version
lazy val dispatch = "net.databinder.dispatch" %% "dispatch-core" % dispatchV
lazy val root = (project in file(".")).
settings(scalaxbSettings: _*).
settings(
name := "hello",
organization := "com.example",
scalaVersion := "2.11.1",
libraryDependencies ++= Seq(scalaXml, scalaParser, dispatch),
packageName in (Compile, scalaxb) := "com.paperstreet",
packageNames in (Compile, scalaxb) := Map(uri("http://schemas.microsoft.com/2003/10/Serialization/") -> "microsoft.serialization"),
dispatchVersion in (Compile, scalaxb) := dispatchV,
async in (Compile, scalaxb) := true,
sourceGenerators in Compile <+= scalaxb in Compile
// logLevel in (Compile, scalaxb) := Level.Debug
)
This is a bug fix release focused on fixing the SOAP code generation. See using SOAP for more details.
xs:AnyType handling. #265asFault not Throwable error. #264 reported by @romainreuillonHttpClientsAsync to use concurrent.Future. #269 reported by @hedefalk--blocking command line option to generate blocking SOAP client.scalaxb package that’s used internally to generate code.scalaxb 1.2.0 generates non-blocking SOAP code by default. Instead of Either[X, A], the SOAP call returns Future[A] and the fault, if any, is thrown as Future’s failure semantics.
// default
def getQuote(symbol: Option[String]): Future[stockquote.GetQuoteResponse]
// async in (Compile, scalaxb) := false
def getQuote(symbol: Option[String]): Either[scalaxb.Fault[Any], stockquote.GetQuoteResponse]
This feature was contributed by @jlavallee and @hoff2 as #213/#259. See using soap for more details.
DatatypeFactory instance to ThreadLocal. #243 contributed by @malaportemixed attribute not being inherited when extending a complex type. #228 reported by @choffmeisterunbounded is nested. #230 reported by @FranklinChenxs:element with default with minOccurs = 1. #245 reported by @albokoxs:enumeration value. #247 reported by @jcrankyxs:element names with symbols when --class-prefix is passed. #251 reported by @romangarciaxs:group parser getting inherited twice. #238 reported by @choeger