2
votes

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.

1

1 Answers

1
votes

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.