Maven does not copy * .xml files to src / test / java for default target / test classes

I haven’t been programming for a while, and I come back to it, and I ran into a very difficult problem. In the past, when I compiled test code from Maven, it would copy all of my * .xml resource files contained in the test sources tree to target/test-classes . But last night, in my current project, it was not so long that I did not expect. Whenever I ran my tests through Maven or Intellij IDEA, the tests failed because they could not find any * .xml files in the class path - they were never copied.

I have old projects on my computer using the exact same .pom file and project structure, and the * .xml files are copied in order.

To solve this problem, I included the following XML in my Maven MOM:

  <testResources> <testResource> <directory>src/test/java</directory> <filtering>false</filtering> <includes> <include>**/*.xml</include> </includes> </testResource> </testResources> 

While this solves the problem, I'm still wondering why I had to go out of my way to tell Maven to copy * .xml files from my test source tree to the target / test class directory manually. As I said, every other old project for the last 2 years copies * .xml files without specifying testResources .

What could be causing this behavior?

+4
source share
2 answers

You should put the resource files in src/test/resources not src/test/java , which is for the java source files.

+7
source

To control which files are (also) copied, see the Resource Plugin Documentation

+1
source

Source: https://habr.com/ru/post/1501805/


All Articles