1

我们将 Jaxb 与包含一些公共部分的不同模式文件一起使用。为了构建它,我们使用来自 JAXB 发行版的 Ant XJCTask:

<xjc classpath="bin" removeOldOutput="yes" schema="main-schema.xsd" target="src" extension="true">
        <arg value="-no-header"/>
        <depends dir=".">
            <filename name="some/dir/included1.xsd"/>
            </depends>
        <produces dir=".">
            <include name="some/package/dir/*.java"/>
            </produces>
    </xjc>

但显然依赖没有影响,因为可以看到运行 ant -verbose:

      [xjc] Checking timestamp of /local0/mginkel/workspace/main-schema.xsd
  [xjc] Checking timestamp of /local0/mginkel/workspace/some/package/dir/Generated1.java
  [xjc] Checking timestamp of /local0/mginkel/workspace/some/package/dir/Generated2.java

有没有办法在 ant.properties 中正确跟踪对包含的依赖项。我只想在必要时重新编译绑定,但如果其中一个包含已更改,我肯定想重新编译。(这是目前不起作用的)。

4

1 回答 1

0

我认为你的dir设置是错误的。这是我们在工作中使用的(它对我们有用):

<xjc schema="${xsd.location}/eviction.xsd" destdir="${src}"
  package="com.onsitemanager.eviction.schema">
  <produces dir="${src}/com/onsitemanager/eviction/schema" includes="*.java"/>
</xjc>

(不要太担心${xsd.location}和的值是什么${src},只要它们对您的 .xsd 文件和源文件存储位置的设置是明智的。)

值得注意的是,这dir是将 .java 文件输出到的目录,并且includes只是*.java.

于 2011-08-09T13:48:47.010 回答