Skip to content

Releases: eed3si9n/scalaxb

1.12.1

25 Aug 03:05
v1.12.1
604e5db
Compare
Choose a tag to compare

Scala 3 compatibility improvements

Continuing the theme from 1.12.0, scalaxb 1.12.1 improves the code generation for Scala 3. In #654 @mrdziuban 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:

  • Passing sequence to a vararg was changed from xs: _* to xs*
  • Self type with refinement was changed from self: A with B => to self: A & B =>
  • Added indentations where there were an offside "Line is indented too far to the left" warning
  • Rewrote some infix usages like value startsWith "{" to Java-style value.startsWith("{") notation
  • Variable initialization was changed from _ to Java-style null
  • Wildcard type argument was changed from _ to ?

behind the scenes

  • Set name of root project to scalaxb-root by @mdedetrich in #648
  • Bump org.apache.maven.plugins:maven-compiler-plugin from 3.11.0 to 3.13.0 in /mvn-scalaxb by @dependabot in #653
  • Bump org.apache.maven.plugin-tools:maven-plugin-annotations from 3.3 to 3.14.0 in /mvn-scalaxb by @dependabot in #662
  • Bump org.apache.maven.plugins:maven-site-plugin from 3.0 to 3.12.1 in /mvn-scalaxb by @dependabot in #646
  • Bump org.apache.maven.plugins:maven-invoker-plugin from 1.5 to 3.6.0 in /mvn-scalaxb by @dependabot in #647
  • Bump junit:junit from 4.13.1 to 4.13.2 in /mvn-scalaxb by @dependabot in #645

new contributors

Full Changelog: v1.12.0...v1.12.1

1.12.0

02 Dec 04:09
v1.12.0
d6facef
Compare
Choose a tag to compare

scalaxbJaxbPackage

scalaxb 1.12.0 supports choosing javax or jakarta for jaxb package name

Compile / scalaxbJaxbPackage := JaxbPackage.Jakarta

This was contributed by @mrdziuban in #613

updates

behind the scene

new contributors

Full Changelog: v1.11.1...v1.12.0

1.11.1

24 Jun 23:39
v1.11.1
a1f71a7
Compare
Choose a tag to compare

updates

  • Fixes soap12_tagless template for Scala 3 by @zarthross in #600
  • Fixes soap11_tagless template for Scala 3 by @ebar in #602
  • Adds support for http4s 0.22.x client generation - httpclients_http4s_0_22.scala.template by @kevin-lee in #601

new contributors

Full Changelog: v1.11.0...v1.11.1

1.11.0

26 Feb 19:01
v1.11.0
60f4233
Compare
Choose a tag to compare

http4s client + tagless final style

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 @zarthross in #596.

updates

  • Moves setting key default values to globalSettings by @eed3si9n in #597

behind the scene

new contributors

Full Changelog: v1.9.1...v1.11.0

1.9.1

11 Feb 18:36
v1.9.1
Compare
Choose a tag to compare

updates

  • Adds Scala 3 support by enumerating transitive self types in the generated code by @fthomas in #595

behind the scene

new contributors

Full Changelog: v1.9.0...v1.9.1

1.9.0

11 Nov 21:28
v1.9.0
Compare
Choose a tag to compare

updates

  • Updates scala-xml to 2.x, and scala-parser-combinators to 2.x on Scala 2.13 #589 by @mrdziuban
  • Fixes type mismatch in scalaxb.scala #584 by @bodduv

behind the scene

quick setup

$ sbt new eed3si9n/scalaxb.g8

new contributors

Full Changelog: v1.8.3...v1.9.0

1.8.3

02 Jan 05:14
v1.8.3
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.8.1...v1.8.3

1.8.2

25 Sep 22:38
v1.8.2
Compare
Choose a tag to compare

Bug fixes

  • Fixes "match may not be exhaustive." error on Scala 2.13 #565 by @kovstas
  • Fixes the code generation of attribute accessor to add attribute prefix #318/#558 by @etitov

1.8.1

07 Mar 01:06
v1.8.1
Compare
Choose a tag to compare

Bug fixes

  • Fixes whitespace handling when whitespace = collapse #556 by @jypma
  • Fixes reserved word handling for Monocle lens generation #539 by @deenar
  • Fixes Monocle lens generation when complexType and element are named the same #555 by @ihhha
  • Fixes random access performance in ElemNameSeqReader #544 by @omatzcoveo
  • Fixes SOAP action encoding #548 by @etitov

1.8.0

09 Sep 17:06
v1.8.0
Compare
Choose a tag to compare

scalaxb 1.8.0 adds Monocle Lens generation feature.

setup

Using the sbt-scalaxb this can be enabled as:

val monocleCore = "com.github.julien-truffaut" %% "monocle-core"  % "2.0.3"
// val monocleMacro = "com.github.julien-truffaut" %% "monocle-macro" % "2.0.3"
val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0"
val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
val dispatchV = "0.12.0"
val dispatch = "net.databinder.dispatch" %% "dispatch-core" % dispatchV

ThisBuild / organization  := "com.example"
ThisBuild / scalaVersion  := "2.12.8"

lazy val root = (project in file("."))
  .enablePlugins(ScalaxbPlugin)
  .settings(
    name          := "foo",
    libraryDependencies ++= Seq(dispatch, scalaXml, scalaParser, monocleCore),
    Compile / scalaxb / scalaxbDispatchVersion := dispatchV,
    Compile / scalaxb / scalaxbPackageName := "com.example.ipo",
    Compile / scalaxb / scalaxbGenerateLens := true,
    Compile / scalaxb / scalaxbUseLists := true,
  )

generated code

This will generate Lenses in the companion objects as follows:

case class PurchaseOrderType(shipTo: ipo.Addressable,
  billTo: ipo.Addressable,
  comment: Option[String] = None,
  items: ipo.Items,
  attributes: Map[String, scalaxb.DataRecord[Any]] = Map.empty) {
  lazy val orderDate = attributes.get("@orderDate") map { _.as[javax.xml.datatype.XMLGregorianCalendar]}
}

object PurchaseOrderType {
  def shipTo: monocle.Lens[PurchaseOrderType, ipo.Addressable] = monocle.Lens[PurchaseOrderType, ipo.Addressable](_.shipTo)((_shipTo: ipo.Addressable) => (purchaseordertype: PurchaseOrderType) => purchaseordertype.copy(shipTo = _shipTo))
  def billTo: monocle.Lens[PurchaseOrderType, ipo.Addressable] = monocle.Lens[PurchaseOrderType, ipo.Addressable](_.billTo)((_billTo: ipo.Addressable) => (purchaseordertype: PurchaseOrderType) => purchaseordertype.copy(billTo = _billTo))
  def comment: monocle.Lens[PurchaseOrderType, Option[String]] = monocle.Lens[PurchaseOrderType, Option[String]](_.comment)((_comment: Option[String]) => (purchaseordertype: PurchaseOrderType) => purchaseordertype.copy(comment = _comment))
  def items: monocle.Lens[PurchaseOrderType, ipo.Items] = monocle.Lens[PurchaseOrderType, ipo.Items](_.items)((_items: ipo.Items) => (purchaseordertype: PurchaseOrderType) => purchaseordertype.copy(items = _items))
  def attributes: monocle.Lens[PurchaseOrderType, Map[String, scalaxb.DataRecord[Any]]] = monocle.Lens[PurchaseOrderType, Map[String, scalaxb.DataRecord[Any]]](_.attributes)((_attributes: Map[String, scalaxb.DataRecord[Any]]) => (purchaseordertype: PurchaseOrderType) => purchaseordertype.copy(attributes = _attributes))

  implicit class PurchaseOrderTypeW[A](l: monocle.Lens[A, PurchaseOrderType]) {
    def shipTo: monocle.Lens[A, ipo.Addressable] = l composeLens PurchaseOrderType.shipTo
    def billTo: monocle.Lens[A, ipo.Addressable] = l composeLens PurchaseOrderType.billTo
    def comment: monocle.Lens[A, Option[String]] = l composeLens PurchaseOrderType.comment
    def items: monocle.Lens[A, ipo.Items] = l composeLens PurchaseOrderType.items
    def attributes: monocle.Lens[A, Map[String, scalaxb.DataRecord[Any]]] = l composeLens PurchaseOrderType.attributes
  }
}

case class Items(item: List[ipo.Item] = Nil)
      
object Items {
  def item: monocle.Lens[Items, List[ipo.Item]] = monocle.Lens[Items, List[ipo.Item]](_.item)((_item: List[ipo.Item]) => (items: Items) => items.copy(item = _item))

  implicit class ItemsW[A](l: monocle.Lens[A, Items]) {
    def item: monocle.Lens[A, List[ipo.Item]] = l composeLens Items.item
  }
}

usage

Here's an example of how the lenses can be used:

scala> import com.example.ipo._
import com.example.ipo._

scala> val items = Items(Item("a", BigInt(0), BigDecimal(0)) :: Nil)
items: com.example.ipo.Items = Items(List(Item(a,0,0,None,None,Map())))

scala> val po = PurchaseOrderType(Address("", "", ""), Address("", "", ""), None, items)
po: com.example.ipo.PurchaseOrderType = PurchaseOrderType(Address(,,),Address(,,),None,Items(List(Item(a,0,0,None,None,Map()))),Map())

scala> PurchaseOrderType.items.item.set(Item("b", BigInt(0), BigDecimal(0)) :: Nil)(po)
res0: com.example.ipo.PurchaseOrderType = PurchaseOrderType(Address(,,),Address(,,),None,Items(List(Item(b,0,0,None,None,Map()))),Map())

In the above, PurchaseOrderType.items.item zooms into the item field of the purchase order's items field and replaces the value.

This was implemented by @eed3si9n as #535, based on #292 contributed by @lbruand.