我们将 Jaxb 与不同的架构文件一起使用,其中包括一些公共(public)部分。 为了构建这个,我们使用 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.h 中正确跟踪包含的依赖关系?我只想重新编译 如有必要,绑定(bind),但如果其中一个包含项发生更改,我绝对想重新编译。 (这是目前不起作用的)。
最佳答案
我认为您的 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
。
关于java - JAXB 与 Ant : How to make XJCTask respect <depends>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6997077/