In order to deploy test resources with WTP, we need to add a new Maven
dev profile to the
<profiles> section of your pom.xml. This can easily be done with
Ctrl+space assist. Selecting the m2e profile template and changing the id to
dev will get you started.
The profile is automatically enabled when running in m2e, via the
Then, you need to add a
maven-war-plugin configuration to the
<build><plugins> section of the new profile, and configure
<webResources> so that test resources from the test output directory are copied to WEB-INF/classes, using a regexp to only include specific files.
Eventually, this is how your dev profile should look :
<property> <!-- this will automatically be enabled when using m2e -->
<!-- this will inherit existing maven-war-plugin configuration-->
In Eclipse, the matching test resources are not served directly but are actually copied/processed to
target/m2e-wtp/web-resources/WEB-INF/classes and deployed from there.
If the original configuration already defines
<webResources combine.children="append"> in the
dev profile, so all resources get deployed. You can learn more about merging plugin configuration on the Sonatype blog.
If you decide to declare this profile in a parent pom, don’t forget to put the
<plugins> node under the
<pluginManagement> section, or else, these configurations will not be inherited by your war projects.
This extra configuration will be merged to your existing
maven-war-plugin configuration (check the
maven-war-plugin configuration in the Effective POM tab of the pom.xml editor).
Now, using m2e-wtp, every time a test resource is modified, it will automatically be deployed to your server, on-the-fly. This is borderline magic, I know.