Maven's Surefire (testing) pluginmvn test-compile
copies files in src/test/resources
to target/test-classes
. It compiles .java
in src/test/java
, and copies the compiled .class
files to target/test-classes
.
But it doesn't copy resources from src/test/java
, and it's more convenient to be able to put test resources in the same directory as the .java
classes they are resources for, than in a parallel hierarchy in src/test/resources
.
Is it possible to get Maven to copy resources from src/test/java
?
The resource copying is all done by the maven-resource-plugin, and if you read the doc thereof you will see how to add copying of resources from src/test/java.
See http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html for the test-resources goal, which is included in the default lifecycle.
And then see http://maven.apache.org/pom.html, and look for <testResources>
.