我可以将单个文本文件打包为 Maven 存储库中的文本文件吗?

发布于 2024-08-26 22:26:41 字数 410 浏览 4 评论 0原文

我有一个配置文件,我想将其作为依赖项包含在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

信愁 2024-09-02 22:26:41

我会将配置文件包装在 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 the generate-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.

断爱 2024-09-02 22:26:41

请参阅此讨论,特别是有关使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文