In a maven project I have several modules which only have a persitence.xml for unit-tests in
src/test/resources/META-INF/persistence.xml
If I build the project with ‘package’ the (unit-test) persistence.xml is copied into the jar file.
The created artifact (jar) is not supposed to have any persistence.xml because it is already contained in a war file which includes several modules.
The poms are very small and have no plugins configured, everything should be the default behaviour.
- What am I doing wrong?
- Is there any documentation available which explains this effect?
When you run Maven with the debug flag, i.e.
mvn -X ...do you see any messages indicating that files fromsrc/testare being copied? If so, you might want to check the Maven goal that performs this activity.Also, you might want to check the contents of the
target/classesandtarget/test-classesdirectories of the project/module after the Maven build. Assuming that the module has a packaging of jar, themaven-jar-pluginmerely picks up the contents of the project’s output directory, i.e.target/classesor${project.build.outputDirectory}while carefully avoiding the project’s test output directory, i.e.target/test-classesor${project.build.testOutputDirectory}. This should also be evident from the output ofmvn -X ....Finally, you might want to check the contents of your local Maven repository for the jar file created. It might so happen that your
maven-war-pluginused to create the WAR file,might be picking an older and incorrect version of the JAR that has the test persistence bundled in it, from the local repository.