maven测试阶段的清单文件

发布于 2024-11-29 11:09:32 字数 579 浏览 3 评论 0原文

我已配置 manifest.mf 文件以添加此处提到的客户属性: http:// twit88.com/blog/2008/02/20/maven-adding-custom-attributes-and-build-timestamp-to-manifest/

我面临的问题是,条目填充在manifest.mf文件中 类/META-INF。但是 test-classes/META-INF 中的 manifest.mf 文件仍然有未被值替换的变量。

为了运行测试,我需要生成测试资源,但 test-classes/META-INF 内的manifest.mf 文件未填充测试目标。

任何人都可以建议一种配置manifest.mf 文件进行测试的方法吗???

请注意,我已经尝试为 maven-antrun-plugin 添加“generate-test-resources”阶段,但它不起作用。

谢谢。

I have configured manifest.mf file to add custome attributes as mentioned here:
http://twit88.com/blog/2008/02/20/maven-adding-custom-attributes-and-build-timestamp-to-manifest/.

The problem i face is, the entries are populated in the manifest.mf file inside
classes/META-INF. But the manifest.mf file inside test-classes/META-INF still have the variables not replaced by values.

For running the tests, i need test resources generated, but manifest.mf file inside test-classes/META-INF is not populated for the test goals.

Can anyone please suggest a way to configure manifest.mf file for tests????

Note that i have already tried adding "generate-test-resources" phase for maven-antrun-plugin but it didnt work.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

淡莣 2024-12-06 11:09:32

构建一个与将要投入生产的测试二进制文件不同的测试二进制文件是一个坏主意。如果清单中有配置,请考虑将其移动到不属于编译代码的配置文件中。然后您就可以拥有配置文件的测试版本和生产版本。

编辑:据我了解,您基本上是在尝试对 pom.xml 进行单元测试。如果我是你,我不会为此烦恼,特别是如果我正在测试一个无论如何都不会成为已编译存档的一部分的文件的内容(测试资源的清单文件)。
但是,您要解决的问题是您想要过滤测试资源,并且可以通过显式声明测试资源并将过滤设置为 true 来实现这一点。

<testResources>
    <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
....

如果您使用的是 maven 2.1 或更高版本,您可以跳过 antrun 内容,只使用 ${maven.build.timestamp} 代替。

Building a test-binary that's different from what will go into production is a bad idea. If you have configuration in the manifest, consider moving it to a config file that isn't part of your compiled code. Then you can have a test and a production version of your config file.

Edit: As I understand it, You're basically trying to unit test your pom.xml. I wouldn't bother with that if I were you, especially if I'm testing the contents of a file that isn't going to be part of the compiled archive anyway (the manifest file of your test resources).
However, the problem you're trying to solve is that you want filtering on your test resources and you do that by explicitly declaring your test resources and setting filtering to true.

<testResources>
    <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
....

If you're using maven 2.1 or later, you can skip the antrun stuff and just use ${maven.build.timestamp} instead.

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