我正在使用jacobono gradle-jaxb-plugin。我尝试从目录中的多个模式文件生成类,同时使用XJB向其中一个类添加注释。我看到以下错误:
[ant:xjc] [ERROR] "file:/src/test/xsd/XSD_ONE_1_0.xsd" is not a part of this compilation. Is this a mistake for "file:/src/test/xsd/XSD_TWO_1_0.xsd"?
[ant:xjc] line 10 of file:/src/test/xsd/xjb/xsd-bindings.xjb
XJB档案:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:annox="http://annox.dev.java.net"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
jaxb:extensionBindingPrefixes="xjc annox" version="2.1">
<jaxb:bindings schemaLocation="../XSD_ONE_1_0.xsd" node="/xs:schema">
<jaxb:bindings node="xs:complexType[@name='SomeNodeName']">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
name="someNodeName" />
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
文件夹结构:
src
test
xsd
xjb
xjb-bindings.xjb
XSD_ONE_1_0.xsd
XSD_TWO_1_0.xsd
相关插件配置:
dependencies {
...
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41'
jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41'
jaxb 'javax.xml.bind:jaxb-api:2.2.7'
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.6.5"
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics:0.6.4"
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-annotate:0.6.4"
jaxb "org.jvnet.jaxb2_commons:jaxb2-value-constructor:3.0"
}
jaxb {
xsdDir = "${project.name}/src/test/xsd"
bindingsDir = "${project.name}/src/test/xsd/xjb"
bindings = ["xsd-bindings.xjb"]
xjc {
taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task"
destinationDir = "generated-sources/jaxb"
args = ["-Xinheritance", "-Xannotate", "-Xvalue-constructor"]
}
}
我确实尝试删除第二个xsd文件,然后它似乎工作,但这不会是一个永久的解决方案。
更新:
我刚刚发现这个人有同样的问题,将其记录为Github上的一个问题。这可能只是插件的一个错误。我将不得不看一下代码。