我可以将单个文本文件打包为 Maven 存储库中的文本文件吗?
我有一个配置文件,我想将其作为依赖项包含在 Maven pom.xml 中。我想保留它的几个版本,并将其出现在类路径中。我意识到我可以将它包装在一个罐子里,但我团队中的其他人希望轻松检查其内容。查看 pom.xml 中允许的类型,我只看到 pom、jar、war、ear 等内容,...基本上只是某种类型的档案。所以我想知道打包单个文件的 pom.xml 可能是什么样子。我会将检查服务器时的 Maven 工件成像为类似的内容
myconfig-0.0.1.cfg
myconfig-0.0.1.cfg.md5
myconfig-0.0.1.cfg.sha1
myconfig-0.0.1.pom
myconfig-0.0.1.pom.md5
myconfig-0.0.1.pom.sha1
那么这可能吗? pom.xml 会是什么样子?
I have a single configuration file which I would like to include as a dependency in a maven pom.xml. I want to keep around several versions of this, and have it appear in the classpath. I realize I could wrap it in a jar, but others in my team would like to easily inspect its contents. Looking at the types allowed in the pom.xml, I only see things like pom, jar, war, ear, ... Basically just archives of some sort. So I'm wondering what the pom.xml might look like to package a single file. I would imaging the maven artifacts on inspecting the server to be something like
myconfig-0.0.1.cfg
myconfig-0.0.1.cfg.md5
myconfig-0.0.1.cfg.sha1
myconfig-0.0.1.pom
myconfig-0.0.1.pom.md5
myconfig-0.0.1.pom.sha1
So is this possible? What would the pom.xml look like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会将配置文件包装在 jar 中,并使用 Dependency 插件
dependency:unpack
< /a> 在generate-resources
阶段生成 jar(请参阅 解压特定工件示例)。这将允许轻松地对其进行版本控制,轻松地将其添加为依赖项,并轻松地检查它。I would wrap the configuration file in a jar and use the Dependency plugin to
dependency:unpack
the jar during thegenerate-resources
phase (see the Unpacking specific artifacts example). This would allow to version it easily, to add it as dependency easily, and to inspect it easily.请参阅此讨论,特别是有关使用 maven-install 插件定义可安装工件的讨论:
https://stackoverflow.com/a/4245890/ 2491903
See this discussion, specifically on using the maven-install plugin to define an installable artifact:
https://stackoverflow.com/a/4245890/2491903