When creating a jar-with-dependencies, the resources in src/test/resources are automatically added to the jar. This folder often contains a .properties file only valid for the test environment and should not be included in the final jar.
resource tag to exclude the directory is ignored by Maven running in Eclipse. It’s not clear why.
Right-click the source folder “src/test/resources” and click “Build Path|Configure Exclusion/Inclusion Filters…”. Add an exclusion filter of
**. Now the resources will not be included in the final jar file.
Testing from Eclipse
When running from eclipse, it is possible to include the content of src/test/resources in the classpath. Here’s how:
- Right-click src/main/java
- Click “Properties”
- Click “Run/Debug Settings”
- Select a Launch Configuration you want to change.
- Click Edit.
- Click the Classpath tab.
- Click Advanced…
- Click Add Folders and Click Ok
- Select the src/test/resources folder on your project.
Now when running from eclipse, the test resources are in the classpath. It maybe necessary to make this change for several launch configurations.