Posts

scalaxb 1.12.4 English

bug fixes

  • 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

scalaxb 1.12.2 English

scalaxb 1.12.2 is released

updates

scalaxb 1.12.2 adds support for Dispatch 2.x, contributed by @urwithsumit in #677

scalaxb 1.12.1 English

scalaxb 1.12.1 is released.

Scala 3 compatibility improvements

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:

  • 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 ?

Full release note is at https://github.com/eed3si9n/scalaxb/releases/tag/v1.12.1

scalaxb 1.11.0 English

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 Darren Gibson (@zarthross) in #596.

updates

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

behind the scene

  • Add scripted test by @eed3si9n in #598

new contributors

Full Changelog: https://github.com/eed3si9n/scalaxb/compare/v1.9.1...v1.11.0

scalaxb 1.7.5

  • toXML(...) で xsi:type 属性を書き出すようにした #518 by @abestel

  • scalaxbUseLists セッティングを追加して Seq[A] の代わりに List[A] を生成できるようにした #526 by @pgrandjean

  • 生成されたコードで複数の引数を取る中置記法を使わないようにする修正 #531 by @margussipria

  • enum が生成する fromString メソッドが大きすぎてコンパイルできない問題の回避として分けるようにした #517 by @LolHens

scalaxb 1.7.2

バグフィックス

  • toXML が呼ばれたときの Big decimal のフォーマットを XML Schema に準拠するよう修正した。#505 by @tOverney

scalaxb 1.7.1

バグフィックス

  • Big decimal のフォーマットを XML Schema に準拠するよう修正した。 #483 by @danslapman

  • String と Option[String] が比較されていたのを修正した。 #485 by @lespea

  • One-way SOAP 呼び出しを修正した。 #493 by @danslapman

scalaxb 1.7.0 English

breaking changes

  • 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._

symbol encoding strategy and capitalization

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")
  }

#461 by @hosamaly

other enhancements

  • Handle multiple faults #438 by @SupraFii
  • Adds support for enum values list #446 by @bbarker
  • Supports Dispatch versions from 0.11.4 to 0.14.x #468 by @margussipria
  • Generates a default value for class parameters of anyAttribute #470 by @hosamaly
  • scala-xml 1.1.0 and scala-parser-combinators 1.1.0 #476 by @sullis
  • Uses sealed traits for enums #479 by @mrdziuban
  • Adds config option for setting scalaxbEnumNameMaxLength for enum name length #480 by @mrdziuban

bug fixes

  • Don’t throw exception on http status code != 200 to allow Fault parsing #444 by @alexdupre
  • Fixes Soap11Fault bug when empty detail #450 by @dportabella

scalaxb 1.5.2

機能改善点

  • Gigahorse 0.3 及び異なるバックエンド (OkHttp と AHC) へのサポートを追加した。 #428 by @alexdupre

バグフィックス

  • JVM のコードサイズの制限を回避するため、fromAnySchemaType を分割するようにした。 #429 by @fltt

scalaxb 1.5.0

互換性の無い変更点

  • 型クラスのインスタンスの名前衝突をパケージ名をプレフィックスすることで修正した。 #385 by @anatoliykmetyuk
  • 可変長引数 (varargs) をデフォルトで使わないように変更した。
  • sbt-scalaxb を auto plugin 化した。

バグフィックス

  • 複数の implicit ヘッダを用いる SOAP operation の修正。 #380 by @joshlreese
  • SOAP ヘッダの値が合成された場合の修正。 #381 by @coutoPL
  • SOAP ヘッダパーツに関連したコード生成の修正。 #400 by @jankeesvanandel
  • enum の名前の衝突の修正。 #386 by @anatoliykmetyuk
  • enum のパーシングを修正して、例えば xsd:byte 型による 00 を取り扱えるようになった。 #388 by @anatoliykmetyuk

機能改善点

  • 可変 (mutable) case class を生成するための --mutable オプションを追加した。詳細は後ほど。
  • type 属性を用いた xs:any の変換。 #389 by @anatoliykmetyuk
  • パッケージ名を自動で選択する --autopackages オプションの追加。 #391 by @anatoliykmetyuk
  • 生成された case class を走査するための Visito を生成する --visitor オプションの追加。 #392 by @anatoliykmetyuk

sbt-scalaxb への変更

scalaxb 1.5.0 より sbt-scalaxb は auto plugin 化される。 scalaxbSettings 追加して、sourceGenerators in Compile する代わりに、ScalaxbPlugin を有効化するだけでよくなった。 他の全てのセッティングやタスクは “scalaxb” とプレフィックスされる。 例えば、以前の packageName というキーは 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
  )

#405 by @eed3si9n

可変 (mutable) case class

scalaxb 1.5.0 は可変な case class を生成するオプションを追加する。

case class Address(var name: String,
  var street: String,
  var city: String)

sbt-scalaxb では以下のように有効化できる:

lazy val root = (project in file(".")).
  enablePlugins(ScalaxbPlugin).
  settings(
    name := "foo-project",
    scalaxbPackageName in (Compile, scalaxb) := "generated",
    scalaxbGenerateMutable in (Compile, scalaxb) := true
  )

#390 by @AndreVanDelft

コントリビューター

バグ報告や pull request によって scalaxb の改善にお手伝いしていただいた皆さんにこの場を借りてお礼します。

git shortlog -sn --no-merges 1.4.1..release/1.5.0 によると今回のリリースでは以下の方々にコントリビュートしてもらった (敬称略): Anatoliy Kmetyuk (@anatoliykmetyuk), Eugene Yokota (@eed3si9n), Andre Van Delft (@AndreVanDelft), Jan-Kees van Andel (@jankeesvanandel), Joshua Reese (@joshlreese), and Mateusz Kołodziejczyk (@coutoPL).

scalaxb 1.4.1

互換性の無い変更点

  • Dispatch 0.11.3 サポートを追加して、defaultDispatchVersion も 0.11.3 へと変更した。 #352 by @DustinChaloupka

バグフィックス

  • implicit 及び explicit な SOAP ヘッダ処理の修正。#366 by @coutoPL

who is using scalaxb? English

Here’s a list of users who are using scalaxb, or have at some point.

Banno

Non-blocking SOAP feature was also contributed by @hoff2 from Banno.

Klout

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.

Novus

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?!”

VMWare vCloud

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.

scalaxb 1.4.0

SOAP/REST 関連の変更点

  • DispatchHttpClients に requestTimeout と connectionTimeout を追加した。 #304 by @eed3si9n
  • --no-dispatch-client オプション (generateDispatchClient := false) を追加した。 #322 by @liff
  • Dispatch の Http(request > as.scalaxb[A]) をサポートするための --dispatch-as オプション (generateDispatchAs := true) を追加した。 #332 by @arkadius

その他の機能改善点

  • 不明な XML 要素や順番違いを無視するための --ignore-unknown オプション (ignoreUnknown := true) を追加した。 #310 by @jet-black
  • 可変長引数のかわりに Seq を使う --no-varargs オプションを追加した。 #292/#309 by @lbruand and @Erwan56
  • 列挙の値が重複している場合の処理を改善した。 #308 by @donderom
  • 設定値を case class の列にリファクタリングした。 #342 by @eed3si9n

バグフィックス

  • 名前空間の重複を修正した。 #310/#291/#298 by @jet-black
  • CompilerMatcher の Windows でのファイル名やパス処理を修正した。 #307 by @joescii

コンパイラの警告

scalaxb 1.4.0 によって生成されるコードから警告が出ないように修正が加えられた。

  • 生成されるコードに SIP-18 インポートを追加した。 #294 by @carl297r
  • 生成されるコード内の “adapting argument list” およびその他のコンパイラ警告を除去した。 #321 by @liff
  • scalaxb 本体のコードからコンパイラ警告を除去した。 #335 by @justjoheinz
  • 生成されるコード内の後置記法を除去した。
  • 統合テスト時に -Xfatal-warnings オプションを追加した。 #343 by @eed3si9n

コントリビューター

バグ報告や pull request によって scalaxb の改善にお手伝いしていただいた皆さんにお礼を言いたい。

git shortlog -sn --no-merges 1.3.0..release/1.4.0 によると今回のリリースでは 10人にコントリビュートしてもらった (敬称略): 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)

scalaxb 1.3.0

互換性の無い変更点

  • SOAP RPC/encoded のサポートの廃止。
  • SOAP の faultactor を String に変更。 #268 by @rubbish
  • 22 case classes をデフォルトで生成するようにした。 #280

  • 全ての属性を取り扱う単一の attributes フィールドでデフォルトで生成するようにした。 #286

SOAP 関連の変更点

  • ヘッダの message parts の取り扱いを修正した。 #285 by @plaflamme
  • nillable な fault の取り扱いを修正した。 #284
  • http のインスタンスを lazy に変更した。 #279 by @rubbish
  • fault の toString を実装した。 #278

case class >22 および属性に関する変更

scalaxb 1.3.0 より、デフォルトで >22 な case class が生成されるようになる。さらに、全ての属性は attribute フィールドにまとめられる。

従来の振る舞いに戻したい場合は以下の設定を行う:

contentsSizeLimit in (Compile, scalaxb) := 20

namedAttributes in (Compile, scalaxb) := true

これに関連して、1.3.0 は属性のデフォルト値の取り扱いを修正した。 #288

sponsors English

Thanks to YourKit for supporting scalaxb! YourKit Java Profiler works great for profiling Scala applications.

scalaxb と Scala 2.11

scalaxb 1.2.0 より Scala 2.11.x をサポートするようになった。Scala 2.11 は XML とパーサコンビネータをモジュール化するため、追加で設定が必要になった。以下は sbt 0.13 のマルチプロジェクト構文を使った例だ:

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    
  )

scalaxb 1.2.1

これは SOAP コード生成に関連したバグ修正に的を絞ったリリースだ。詳細は SOAP を使うを参照。 .

SOAP 関連のバグフィクス

  • xs:AnyType の処理を修正した。 #265
  • asFaultのエラーを修正した。 #264 reported by @romainreuillon
  • マルチパート SOAP メッセージにより生成されるコードを修正した。 #267 reported by @tomhaigh
  • HttpClientsAsync にて concurrent.Future を使うように修正した。 #269 reported by @hedefalk
  • ブロッキング SOAP クライアントを生成する --blocking というコマンドラインオプションを追加した。

細かな機能改善点

  • コードの生成に内部で使っている scalaxb パッケージを別名にマスクした。

scalaxb 1.2.0

ノンブロッキング SOAP

scalaxb 1.2.0 よりデフォルトでノンブロッキングな SOAP コードを生成がされるようになった。これまでの Either[X, A] の代わりに SOAP 呼び出しは Future[A] を返し、もし Fault がある場合は Future の失敗として投げられる。

// 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]

この機能は @jlavallee と @hoff2 によって #213/#259 としてコントリビュートされた。詳細は soap を使う を参照。

SOAP 関連のバグフィクス

  • SOAP内のパラメータに現れる予約語をエスケープするようにした。 #252/#256 contributed by @romainreuillon
  • SOAP内のオペレーション名に現れる予約語をエスケープするようにした。 #241 reported by @rcgoodfellow
  • SOAP内での nillable な要素の扱いを修正した。 #229 reported by @barnesjd
  • SOAP を POST したときのエンコーディング問題を修正した。 #231 reported by @hedefalk
  • Dispatch 0.11.1 に対応した。
  • literal RPC スタイルのときのレスポンスのパースを修正した。 #260 reported by @romainreuillon

その他のバグフィクスおよび細かな機能改善点

  • Scala 2.9.0 のサポートから除外して、廃止勧告の出ている呼び出しを修正した。
  • DatatypeFactory を ThreadLocal にキャッシュするようにした。 #243 contributed by @malaporte
  • 長さがゼロのプレフィックスの処理を修正した。 #253/#255 contributed by @romainreuillon
  • 複合型の継承時に mix 属性が正しく継承されない問題を修正した。 #228 reported by @choffmeister
  • unbounded が入れ子になったときに、パーサが終了しない問題を修正した。 #230 reported by @FranklinChen
  • xs:element が default および minOccurs = 1 であるときの処理を修正した。 #245 reported by @alboko
  • xs:enumeration の値が非常に長い場合の処理を修正した。 #247 reported by @jcranky
  • xs:element の名前にシンボルが入っていて、かつ --class-prefix が渡されたときの処理を修正した。 #251 reported by @romangarcia
  • xs:group のパーサが複数回継承される問題を修正した。 #238 reported by @choeger