我们有一组通用的 XSD(数据类型、词汇表等),我们在其自己的 Maven 项目中使用 jaxb2-maven-plugin 生成。在第二个项目中,我需要在编译时引用这些 XSD 中的一个或多个,但不希望它们包含在生成的 Artifact 中。我已经创建了一个目录文件,它工作正常,但我得到了其中的所有内容。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<target>2.1</target>
<catalog>catalog.cat</catalog>
</configuration>
我仔细研究了 plugin docs ,但他们对细节的关注度很低。有没有什么方法可以重用通用模式,而无需每个项目都复制它们?
谢谢
最佳答案
这是我的 maven-jaxb2-plugin
可以做的事情:
Compiling schema from Maven Artifact
文档站点目前非常不稳定,所以这里是文档的片段。
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<dependencyResource>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-tests-po</artifactId>
<!-- Can be defined in project dependencies or dependency management -->
<version>${project.version}</version>
<resource>purchaseorder.xsd</resource>
</dependencyResource>
</schema>
</schemas>
</configuration>
这是一个 sample project .
关于maven - 具有外部 XSD 依赖项的 jaxb2-maven-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22845687/