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    
  )