如何配置<清单>仅在桌面应用程序的 pom.xml 中出现一次清单>
我正在使用 maven 制作一个 swing 应用程序,并尝试严格控制 pom.xml (在粘贴我们在 google 中找到的任何内容后,该文件往往会变成一堆垃圾)。
我的 pom 带有 jar,我使用带有“jar-with-dependencies”描述符的 maven- assembly-plugin 。 因此,我需要定义项目的两次部分(主类和版本),一次用于普通 jar,另一次用于 jar-with-dependencies。
我认为问题来自于 jar-with-dependency 程序集描述符,它不是解压正常的 jar 并融合清单,而是从 ${project.build.outputDirectory} 创建一个新的 jar,这对我来说闻起来很奇怪。
有人有一个紧凑而优雅的想法来避免重复我的清单配置吗?
谢谢, 尼古拉斯.
I'm making a swing application with maven and I try to keep the pom.xml under tight reins (this file tends to become a pile of junk after pasting there whatever we find in google).
My pom is with jar and I use the maven-assembly-plugin with "jar-with-dependencies" descriptor.
So I need to define twice the part of my project (main class and versions), once for the normal jar and the other once for the jar-with-dependencies.
I think the problem comes from the jar-with-dependencies assembly descriptor, instead of unpacking the normal jar and fusion the manifests, it creates a new jar from ${project.build.outputDirectory} wich smells strange to me.
Does anybody have a compact and elegant idea to avoid this repetition of my manifest configuration ?
Thanks,
Nicolas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以配置 程序集 和 jar 插件来使用[特定清单文件。从程序集文档的创建可执行 Jar 部分:
请注意,您定义的清单将与生成的内容合并。从引用的 jar 页面:
以下配置将程序集插件执行绑定到 pre-integration-test 阶段(打包后的下一个阶段),并且还将包含 src/main/resources/META-INF 下定义的 MANIFEST.MF 。
因此,按照这种方法,您可以在 MANIFEST.MF 中定义通用清单内容,并将它们合并到最终清单中。
src/main/resources/META-INF/MANIFEST.MF 的内容
更新:
根据有关使用 addDefaultSpecificationEntries 的评论,建议的方法将与 jar 插件生成的 jar 上的规范结合使用。然而,看起来程序集插件尚不支持合并附加声明。 jar 插件将 src/main/resources 中的清单与附加指定的值合并,以在我的测试项目中提供此内容:
而 assembly-plugin 的输出是:
config:
You can configure both the assembly and jar plugins to use a [particular manifest file. From the Creating an Executable Jar section of the assembly docs:
Note the manifest you define is merged with the generated content. From the referenced jar page:
The following configuration binds the assembly-plugin execution to the
pre-integration-test
phase (the next phase after package) and will also include the MANIFEST.MF defined under src/main/resources/META-INF.So following this approach, you can define the common manifest contents in your MANIFEST.MF and have them be merged into the final manifest.
contents of src/main/resources/META-INF/MANIFEST.MF
Update:
Based on the comments about using addDefaultSpecificationEntries, the suggested approach will work in conjunction with that specification on the jar produced by the jar plugin. However it looks like the assembly plugin doesn't yet support merging the additional declarations. The jar plugin merges the manifest from src/main/resources with the additionally specified values to give this content on my test project:
Whereas the output from the assembly-plugin is:
config: