Playframework 2.4 - 如何包含scalaxb

时间:2016-03-11 11:19:48

标签: scala playframework playframework-2.4 scalaxb

build.sbt代码: 我复制了http://scalaxb.org/sbt-scalaxb

中的代码
name := """DealerNext"""

version := "1.0-SNAPSHOT"

import ScalaxbKeys._

lazy val commonSettings = Seq(
  organization  := "com.dn",
  scalaVersion  := "2.11.5"
)

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(".")).
  enablePlugins(PlayScala).
    settings(commonSettings: _*).
  settings(
    name          := "nada",
    libraryDependencies ++= Seq(dispatch),
    libraryDependencies ++= {
      if (scalaVersion.value startsWith "2.11") Seq(scalaXml, scalaParser)
      else Seq()
    }).
  settings(scalaxbSettings: _*).
  settings(
    sourceGenerators in Compile += (scalaxb in Compile).taskValue,
    dispatchVersion in (Compile, scalaxb) := dispatchV,
    async in (Compile, scalaxb)           := true
    packageName in (Compile, scalaxb)     := "generated"
    // packageNames in (Compile, scalaxb)    := Map(uri("http://schemas.microsoft.com/2003/10/Serialization/") -> "microsoft.serialization"),
    // logLevel in (Compile, scalaxb) := Level.Debug 
  )

scalaVersion := "2.11.6"
scalacOptions ++= Seq("-Xmax-classfile-name", "100")
libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  specs2 % Test,
  "io.swagger" %% "swagger-play2" % "1.5.0",
  "com.typesafe.play" %% "anorm" % "2.4.0",
  filters,
  "net.kaliber" %% "play-s3" % "7.0.2"
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
resolvers += "OSS Repo" at "https://oss.sonatype.org/content/repositories/snapshots"
resolvers += "Kaliber Internal Repository" at "https://jars.kaliber.io/artifactory/libs-release-local"
resolvers += Resolver.sonatypeRepo("public")

//"com.cloudphysics" % "jerkson_2.10" % "0.6.3"

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

packageName in(Compile,scalaxb):=" generated"这一行引发了以下错误

error: reference to packageName is ambiguous;
it is imported twice in the same scope by
import ScalaxbKeys._
and import _root_.com.typesafe.sbt.SbtNativePackager.autoImport._
    packageName in (Compile, scalaxb)     := "generated"
    ^

如果我评论该行,则wsdl文件未编译为scala文件。

1 个答案:

答案 0 :(得分:1)

更改

readBuffer

import ScalaxbKeys._

并且

import ScalaxbKeys.{packageName => scalaxbPackageName, _}

packageName in (Compile, scalaxb) := "generated"