覆盖sbt-xjc插件中的sourceManaged

时间:2013-07-04 08:39:54

标签: sbt xjc

我正在使用sbt-xjc插件来生成我的xml类。

sourceManaged的默认值前缀为xjc。我想删除xjc。我该怎么做?

2 个答案:

答案 0 :(得分:0)

对我来说,将以下内容添加到project / build.scala中:

++ Seq(
    sourceManaged in (Compile, SbtXjcPlugin.xjc) <<= sourceManaged

整个文件如下所示:

import com.github.retronym.sbtxjc.test.BaseScriptedTestBuild
import com.github.retronym.sbtxjc.SbtXjcPlugin
import sbt._
import Keys._

object build extends BaseScriptedTestBuild {
  lazy val root = {

    Project(
     id = "main",
      base = file("."),
      settings = Defaults.defaultSettings ++ scriptedTestSettings ++ SbtXjcPlugin.xjcSettings  ++ Seq(
        resolvers += "Java Net" at "http://download.java.net/maven/2/"
      )++ Seq(
        sourceManaged in (Compile, SbtXjcPlugin.xjc) <<= sourceManaged
      )
    );
  }
}

答案 1 :(得分:0)

build.sbt中使用此配置,XJC直接在src_managed/main中生成类。

SbtXjcPlugin.xjcSettings ++ Seq(
  sources in (Compile, xjc) <<= baseDirectory map (_ / "xsd" ** "*.xsd" get),
  sourceManaged in (Compile, xjc) <<= sourceManaged / "main"
)

XJC将在/xsd中查找xsd文件,并在/target/scala-2.x/src_managed/main

中输出生成的类