引用位于不同项目模块中的不同 XML 的 XSD 文件?
我有一个 XSD 文件,在不同项目模块的三个不同 XML 文件中引用,使用:
<item-groups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xml_schemas/item_groups.xml.xsd">
我一直在尝试弄清楚如何避免手动将 XSD 复制到需要它的每个模块中,因此我不必维护三个文件之一。
Maven 有没有一种方法可以让我的一个模块中只有一个版本,并在构建时将其复制到其他两个模块?
谢谢!
I have an XSD file that is referenced in three different XML files in different project modules using:
<item-groups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xml_schemas/item_groups.xml.xsd">
I have been trying to figure how to avoid manually copying the XSD into every module that needs it, so I don't have to maintain three files instead of one.
Is there a way in maven that I can have only one version in one of my modules, and at build time it copies it over to the other two?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 XSD 至少打包在一个模块中,那么应该可以使用 Maven Dependency 插件和
依赖项:解包
。这个想法是将目标绑定在generate-resources
上,从包含它的模块中解压XSD(使用includes来准确地获取你想要的内容)并在需要的地方编写它。请参阅解压特定工件以获取完整信息例子。Assuming the XSD is packaged in at least one module, it should be possible to achieve what you want with the Maven Dependency plugin and
dependency:unpack
. The idea would be to bind the goal ongenerate-resources
to unpack the XSD from the module having it (using includes to pick up exactly what you want) and write it where required. See the Unpacking specific artifacts for a full example.