如何告诉maven-jaxb2-plugin在maven依赖项中的所有.xsd文件上运行xjc ?



我正在使用maven-jaxb2-plugin,我的.xsd文件位于maven依赖项中。文档显示,在maven依赖项中指定一个.xsd,如下所示

<schema>
    <!-- Specifies a schema from the Maven artifact. -->
    <dependencyResource>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin-tests-po</artifactId>
        <!--  Version of the artifact. May be omitted.
        The plugin will then try to find the version using
        the dependencyManagement and dependencies of the project. -->
        <version>${project.version}</version>
        <!-- Path of the resource within the artifact. -->
        <resource>purchaseorder.xsd</resource>
    </dependencyResource>
</schema>

我想在依赖的.jar文件中的所有.xsd文件上运行xjc。.xsd文件位于.jar文件中的不同目录中。我已经试过了

<resource>**/*.xsd</resource>

但是这个Exception

失败了
org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'maven:com.dg:XSD:jar::5.0.3.4!/**/*.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

是否有一种方法可以在mvn依赖项中指定所有.xsd文件,当它们位于不同的目录中时?

另外,xjc可以在一组.xsd文件上排序依赖树,其中一个.xsd文件依赖于另一个文件,而另一个文件可能依赖于另一个文件,…?

谢谢。

是否有一种方法可以在mvn依赖项中指定所有.xsd文件,当它们位于不同的目录中时?

不,目前你必须指定单独的模式文件。您不需要指定所有这些,只需要指定"根"。请随意提出问题。

另外,xjc可以在一组.xsd文件上排序依赖树,其中一个.xsd文件依赖于另一个文件,而另一个文件可能依赖于另一个文件,…?

是的,XJC递归地解析模式依赖关系。您可以编译一个大而深的模式林,我经常这样做。

最新更新